Evoo

Factorial Java ./Evoo

May 8th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. /*
  2.  * NRP : 151-111-082
  3.  * Name : Stevanus Evo
  4.  */
  5. package javaapplication4;
  6. import java.util.Scanner;
  7. public class JavaApplication4 {
  8.     public static void main(String args[]){
  9.       Scanner scanner = new Scanner(System.in);
  10.       System.out.println("Masukan Angka:");
  11.       int num = scanner.nextInt();
  12.       int factorial = fact(num);
  13.       System.out.println("Factorial dari => "+num+" adalah "+factorial);
  14.    }
  15.    static int fact(int n)
  16.    {
  17.        int output;
  18.        if(n==1){
  19.          return 1;
  20.        }
  21.        output = fact(n-1)* n;
  22.        return output;
  23.    }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment