membuat faktorial dengan perulangan while pada java




import java.io.*;
public class FaktorialWhile{
 public static void main(String [] arg) throws Exception
 {
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 System.out.print("inputkan nilai =");
 String x = br.readLine();
 int a = Integer.parseInt(x);
 long hasil = 1;
 while(a > 0)
 {
  hasil = hasil*a;
  a--;
 }
 System.out.print(hasil);
 }
}





Post a Comment

0 Comments