Prime Factor CPP/C++

Posted by Didi Setyapramana On 9:11 PM 0 komentar

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    long unsigned int nUserInput;
    cin >> nUserInput;
    for(long unsigned int nIterator = 2; nIterator <= nUserInput; nIterator++)
    {
             if((nUserInput % nIterator) == 0)
             {
                            cout << nIterator;
                            nUserInput /= nIterator;
                            nIterator = 1;
                            if(nIterator != nUserInput) {
                                         cout << " * ";
                            }
             }
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}

Categories:
Reaksi: 

0 Response for the "Prime Factor CPP/C++"

Post a Comment