#include
#include
using namespace std;
bool prost(int m){
int k = 0;
for (int i=2; i<=sqrt(m); i++)<br> if (m % i == 0) k++;
return k==0;
}
int main(){
int n, r;
int i = 1;
cout << "n = ", cin >> n, cout << "\n";<br> if (prost(n)) {
cout << "1 * " << n << " = " << n << "\n";}<br> else {
r = n;
while (r != 1){
i++;
if (prost(i)){
while (r % i == 0){
r = r / i;
cout << i;<br> if (r != 1) cout << "*";<br> }
}
}
cout << "=" << n << "\n";<br> }
return 0;
}
Пример:
n = 2720
2*2*2*2*2*5*17=2720