백준 1676번(Java)

박은지·2025년 2월 4일
0

백준

목록 보기
17/89
post-thumbnail

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 cnt = 0;
		
		// 소인수분해 사용
		// 0이 나오려면 2 x 5 여야함
		// 5의 개수가 곧 N!의 0 개수
		while(N >= 5) { 
			cnt += N / 5;
			N /= 5;
		}
		
		System.out.println(cnt);
	}
}
profile
백엔드 개발자가 되고싶은 eunzi😊

0개의 댓글