Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
576 B
3
Indexable
Never
#include <fstream>

using namespace std;

ifstream fin ("factorial.in");

ofstream fout ("factorial.out");

int d = 2, p, i, r;

int n;

int main()
{
    while (fin >> n)
    {
    i=1;
    r=1;
    while (i<=n)
    {
       r = r*i;
       i++;
    }
    while(r > 1)
    {
        p = 0;
        while(r % d == 0)
        {
            p++;
            r = r/d;
        }
        if(p)
            fout<< p << " ";
        d++;
        if(r>1 && d * d > r)
        {
            d = r;
        }
    }
    d=2;
    }
    return 0;
}
Leave a Comment