Skip to content

Commit dc6b65c

Browse files
Add files via upload
1 parent f813a8a commit dc6b65c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Practicals/Factorial.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import java.util.Scanner;
2+
3+
public class Factorial {
4+
static int fact(int n)
5+
{
6+
return (n==1)?1:n*fact(n-1);
7+
}
8+
public static void main(String[] args) {
9+
System.out.println("Enter number: ");
10+
Scanner ob=new Scanner(System.in);
11+
int n=ob.nextInt();
12+
System.out.println("Factorial: "+fact(n));
13+
ob.close();
14+
}
15+
}

0 commit comments

Comments
 (0)