백준 알고리즘 기초/수학

[백준][수학]팩토리얼 0의 개수

코딩고치 2019. 9. 11. 02:23

N!을 소인수분해 하였을 때 5의 개수를 구하면 되는 문제.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;
 
int main(void)
{
    int n;
    cin >> n;
    int count = 0;
 
    for (int i = 5; i <= n; i *= 5)
    {
        count += n / i;
    }
    cout << count << '\n';
    return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter