#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, count = 0;
cin >> n;
while (1) {
int k = n;
n--;
if (k == 0)
break;
while (1) {
if (k % 5 == 0) {
k /= 5;
count++;
}
else
break;
}
}
cout << count;
return 0;
}
팩토리얼의 경우 소인수분해를 했을 때 5가 2보다 훨씬 적기 때문에 수를 5로 나누었을 때 나누어지는 횟수를 변수 count에 차근차근 더해주면 답을 구할 수 있다.