알고리즘/일반(단순구현)

[백준] 1676번 팩토리얼 0의 개수 #Java

VIPeveloper 2022. 6. 7. 09:28
728x90
반응형

소인수분해, 누적합

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int answer = 0;
        while (n >= 5) {
            answer += n / 5;
            n /= 5;
        }
        System.out.println(answer);
    }
}
728x90
반응형