Advertisement
febri321

java faktorial

Oct 14th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package algoritma;
  6.  
  7. /**
  8.  *
  9.  * @author aldi
  10.  */
  11. import java.util.Scanner;
  12. public class faktorial {
  13. public static void main(String [] args) {
  14.     Scanner input = new Scanner(System.in);
  15.     System.out.println ("masukan angka faktorial");
  16.     int angka;
  17.     angka = input.nextInt();
  18.     int hasil = 1 ;
  19.     int jumlah = 1;
  20.     while (jumlah<=angka) {
  21.         hasil=hasil*angka;
  22.         angka = angka - 1;
  23.         System.out.print(""+angka+" x ");
  24.     }
  25.     System.out.println(" faktorial"+angka*angka);
  26.    
  27.    
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement