Skip to content

Commit e84ada1

Browse files
factorial using recursion
algorithms
1 parent 5083f9f commit e84ada1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

factorial using recursion

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.Scanner;
2+
public class practice {
3+
4+
public static int aj(int b)
5+
{
6+
if(b>=1) {
7+
return b * aj(b - 1);
8+
}
9+
else
10+
{
11+
return 1;
12+
}
13+
}
14+
15+
public static void main(String[] args)
16+
{
17+
Scanner sc=new Scanner(System.in);
18+
int a;
19+
System.out.println("enter the number");
20+
a=sc.nextInt();
21+
int t=aj(a);
22+
System.out.println(t);
23+
}
24+
25+
26+
27+
}

0 commit comments

Comments
 (0)