How can we divide a number which is not a prime number into the multiply of prime number? Here is a conclusion:
If one number is not a prime number, and can be divided into two or more numbers, than the numbers will be smaller than its sqrt.
For example, input some numbers, you have to print a line in the output for each entry with the divide numbers. The program is:
#include <iostream>
using namespace std;
int main() {
int N;
while (cin >> N) {
for (int i = 2; i * i <= N; i++) {
if (N % i == 0) {
N /= i;
cout << i << "*";
i = 1;
}
} //The key is any number can be divide by 1, and 2 when it's a even
//number, and 3 when it's a odd number but not a prime number.
cout << N << endl;
}
return 0;
}