33 lines
443 B
C++
33 lines
443 B
C++
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
void scomponiInFattoriPrimi(int n);
|
|
|
|
int main(void) {
|
|
int n = 255;
|
|
|
|
scomponiInFattoriPrimi(n);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void scomponiInFattoriPrimi(int n) {
|
|
while (n % 2 == 0) {
|
|
cout << 2 << " ";
|
|
n = n / 2;
|
|
}
|
|
|
|
for (int i = 3; i * i <= n; i = i + 2) {
|
|
while (n % i == 0) {
|
|
cout << i << " ";
|
|
n = n / i;
|
|
}
|
|
}
|
|
|
|
if (n > 2) {
|
|
cout << n;
|
|
}
|
|
|
|
cout << endl;
|
|
} |