Cod sursa(job #1170078)
| Utilizator | Data | 12 aprilie 2014 17:23:25 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
// 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()
{
int n,twos=0,fives=0;
scanf("%d",&n);
while (n > 0)
{
twos += two(n);
fives += five(n);
n--;
}
printf("%d",min(twos, fives));
return 0;
}
