Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Faktorial {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = scanner.nextInt();
- System.out.println(faktorial(n));
- }
- //Method Faktorial
- public static int faktorial(int a){
- if (a==1) {
- System.out.print(1 + " = ");
- return 1;
- }
- System.out.print(a+" x ");
- return a*faktorial(a-1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement