/*Name: Muhammad Azri bin Jasni @ Abdul Rani
**http://projecteuler.net/problem=3
**The prime factors of 13195 are 5, 7, 13 and 29.
**What is the largest prime factor of the number 600851475143?
*/
/* http://www.physicsforums.com/showthread.php?t=404653
Something to keep in mind is that you don\'t have to check all of the integers from 2 to num.
It is sufficient to go up to sqrt(num) - or the largest integer greater than or equal to sqrt(num).
The idea is that if num has a factor smaller than sqrt(num), then there will be one larger than sqrt(num) as well.
For example, suppose num is 85. All you need to do is check the integers from 2 though 9.
Check 2 - not a divisor.
Check 3 - not a divisor.
Check 4 - not a divisor.
Check 5 - is a divisor. (The other divisor is 17.)
Check 6 - not a divisor.
Check 7 - not a divisor.
Check 8 - not a divisor.
Check 9 - not a divisor.
FYI, you don\'t actually need to check 4, 6, 8, 10, etc. If 2 is not a divisor,
then no other even integer will be a divisor. The same is true for 6, 9, 12, etc.
If 3 isn\'t a divisor, then neither will any other multiple 3 be a divisor.
There are lots of ways to make the program more efficient, but they add complexity to the code.
*/
#include <iostream>
using namespace std;
int main()
{
long long num;
cout << "Enter a number:";
cin >> num;
for (long long i=2; i<=num ; i++)
{
while (num % i == 0)
{
num /= i;
cout << i << " ";
}
}
cout << endl;
//cin.ignore(11000,\'\\n\');
//cin.get();
return 0;
}