Skip to content

Commit

Permalink
B_1929
Browse files Browse the repository at this point in the history
  • Loading branch information
likppi10 committed Oct 31, 2021
1 parent aba2b26 commit 96f1f9a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Algorithm_Baek/Basic/B_300/B_1676_팩토리얼0의개수.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package B_300_수학1;

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

public class B_1676_팩토리얼0의개수 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Long N = Long.parseLong(br.readLine());
int cnt_2 = 0;
int cnt_5 = 0;

for(int i=1; i<=N; i++) {
int target = i;

while((target % 2 == 0)) {
cnt_2++;
target = target / 2;
}

while((target % 5 == 0)) {
cnt_5++;
target = target / 5;
}
}

System.out.println(Math.min(cnt_2, cnt_5));
}
}

0 comments on commit 96f1f9a

Please sign in to comment.