Skip to content

Instantly share code, notes, and snippets.

@dalcon10028
Created March 8, 2020 10:31
Show Gist options
  • Select an option

  • Save dalcon10028/557e87c34ba7b7f44333201ebf77fb8f to your computer and use it in GitHub Desktop.

Select an option

Save dalcon10028/557e87c34ba7b7f44333201ebf77fb8f to your computer and use it in GitHub Desktop.
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] num = new int[2]; // 2의 배수는 0, 5의 배수는 1
for(int i=1; i<=n; i++){
int tmp=i;
while(tmp%2==0){
tmp/=2;
num[0]++;
}
while(tmp%5==0){
tmp/=5;
num[1]++;
}
}
System.out.print(Math.min(num[0], num[1]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment