Skip to content

Instantly share code, notes, and snippets.

@Arjun2002tiwari
Created January 18, 2022 17:19
Show Gist options
  • Save Arjun2002tiwari/345a1ea6c3e06aeeba5dfb4a42947318 to your computer and use it in GitHub Desktop.
Save Arjun2002tiwari/345a1ea6c3e06aeeba5dfb4a42947318 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Factorial{
public static void main(String[] args) {
int i=10,num,fact=1,count=0;
Scanner sc=new Scanner(System.in);
num=sc.nextInt();
int n=num;
while(num>0){
fact=fact*num;
num--;
}
while(fact%i==0){
count++;
i=i*10;
}
System.out.println("Number of zeros in factorial of "+n+" is "+count);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment