Pagini recente » Istoria paginii runda/tineriprogr2 | Cod sursa (job #1352684) | Autentificare | Cod sursa (job #386469) | Cod sursa (job #1170081)
// IAfactorial.cpp : Defines the entry point for the console application.
//
#include<stdio.h>
using namespace std;
inline int min(int x, int y)
{
return (x < y) ? x : y;
}
int five(int x)
{
int y = x,k=0;
while (!(y % 5))
{
y = y / 5;
k++;
}
return k;
}
int two(int x)
{
int y = x, k = 0;
while (!(y%2))
{
y = y / 2;
k++;
}
return k;
}
int main()
{
FILE *in, *out;
in = fopen("factorial.in","r");
out = fopen("factorial.out", "w");
int n,twos=0,fives=0;
fscanf(in,"%d",&n);
while (n > 0)
{
twos += two(n);
fives += five(n);
n--;
}
fprintf(out,"%d",min(twos, fives));
return 0;
}