Skip to content

Commit 18f2814

Browse files
authored
Create FaktoriyelRecursive.java
1 parent c8c68ae commit 18f2814

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

FaktoriyelRecursive.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.company;
2+
3+
import java.util.Scanner;
4+
5+
public class FaktoriyelRecursive {
6+
public static void main(String args[]){
7+
Scanner scanner = new Scanner(System.in);
8+
System.out.print("Sayı Giriniz: ");
9+
int sayi = scanner.nextInt();
10+
int faktoriyel = faktoriyel(sayi);
11+
System.out.println(sayi+"! = "+faktoriyel);
12+
}
13+
14+
public static int faktoriyel(int sayi){
15+
if(sayi == 1){
16+
return 1;
17+
}else{
18+
return sayi*faktoriyel(sayi-1);
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)