Skip to content

Instantly share code, notes, and snippets.

@syafdia
Last active December 11, 2015 11:59
Show Gist options
  • Save syafdia/4597961 to your computer and use it in GitHub Desktop.
Save syafdia/4597961 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class TesFactorial
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int []tot = new int[100];
int num, max, i;
//Input T
max = scan.nextInt();
scan.nextLine();
//Input n
for(i=1;i<=max;i++)
{
num = scan.nextInt();
//Cari hasil bagi nilai n , dan simpan dlm tot
//utk mencari banyak angka 0 pada n faktorial
while(num>=5)
{
num = num/5;
tot[i] = tot[i]+num;
}
}
// tampilkan bnyak angka 0
for(i=1;i<=max;i++)
{
System.out.println(tot[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment