public class faktorial{
public static void main(String[] args) {
Scanner masuk=new Scanner(System.in);
int h,r;
r = 1;
System.out.print("\nMasukan Bilangan : ");
h = masuk.nextInt(); // 3
System.out.println();
System.out.print("Menghitung ==> ");
for(int i = h /*3*/ ; i >= 1; i--) {
r *= i; // r= r*i; r=6
System.out.print(i+" x ");
}
// 3x6x1x
System.out.print("\b\b \n\nNilai Faktorial " + h + " adalah " +r+"\n");
}
}
0 komentar:
Posting Komentar