Cod sursa(job #273980)

Utilizator cryowarCristian Barbu cryowar Data 9 martie 2009 12:09:28
Problema GFact Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<iostream.h>
#include<math.h>
#include<fstream.h>
long long p,a;
int q;
long b;


ifstream f ("gfactin.txt");
ofstream g ("gfactout.txt");

int fact(int x)
{
    if(x==0||x==1) return 1;
    else return x*fact(x-1);
}

main()
{             f>>p>>q;
              a=pow(p,q);
      
              int k=1;
              for(int i=1;i<=p*q && k;i++) if(fact(i) % a==0) {k=0;b=i;}
      
      g<<b;
}