소인수 분해
int N;
cin>>N;
int divider = 2;
for (int i = 2; i*i<=N; i++) {
while(N % i == 0) {
cout<<i<<" ";
N /= i;
}
}
if(N > 1) {
cout<<N;
}Last updated
Was this helpful?
int N;
cin>>N;
int divider = 2;
for (int i = 2; i*i<=N; i++) {
while(N % i == 0) {
cout<<i<<" ";
N /= i;
}
}
if(N > 1) {
cout<<N;
}Last updated
Was this helpful?
Was this helpful?