Last active
December 11, 2015 11:59
-
-
Save syafdia/4597961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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