Wednesday, December 3, 2014

[JAVA] Menentukan Maksimum Faktorial dari Masukkan Sebuah Input

import java.util.Scanner;
public class FatorialPret2 {
    public static void main(String[] args) {
        Scanner masuk = new Scanner(System.in);
        System.out.print("\nAyolah Masukkan Bilangan: ");
        long bilangan = masuk.nextInt();
        long faktorial = 1L;
        System.out.print("\n");
        for(long i = 1L; i <= bilangan; i++){
            faktorial = 1L;
            for(long faktor = 2; faktor <= i; faktor++){
                faktorial *= faktor;
            }
        System.out.println("Faktorial dari "+i+" adalah " +faktorial);
        }
    }
}

No comments:

Post a Comment