Faktorial
public class faktorial
{
public static void main(String[] args)
{
int f;
int n;
Scanner input=new Scanner(System.in);
System.out.print("masukkan nilai f: ");
f=input.nextInt();
System.out.print("masukkan nilai n: ");
n=input.nextInt();
for (int i=1 ; i<=n ; i++) f*=i;
System.out.println(n+"! ="+f);
}
}
Tidak ada komentar:
Posting Komentar