Cod sursa(job #27766)

Utilizator dj_vladootzCostica Vlad dj_vladootz Data 7 martie 2007 08:43:29
Problema Zero 2 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.34 kb
#include<fstream.h>
int main()
{
unsigned long int n,b,i,j,a,p=1,z;
ifstream f("zero2.in");
ofstream g("zero2.out");
a=1;
while(a<=10)
	{
	f>>n>>b;
	p=1;
	i=1;
	while(i<=n)
		{
		for(j=1;j<=i;j++)
			{
			p=p*j;
			}
		i++;
		}
	z=0;
	while(p!=0&&p%b==0)
		{
		z++;
		p=p/b;
		}
	g<<z<<'\n';
        a++;
	}
return 0;
}