We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 18f8dfc + fa3da3d commit a1885d1Copy full SHA for a1885d1
factorialno
@@ -0,0 +1,24 @@
1
+package Edureka;
2
+import java.util.Scanner;
3
+public class Factorial {
4
+public static void main(String args[]){
5
+//Scanner object for capturing the user input
6
+Scanner scanner = new Scanner(System.in);
7
+System.out.println("Enter the number:");
8
+//Stored the entered value in variable
9
+int num = scanner.nextInt();
10
+//Called the user defined function fact
11
+int factorial = fact(num);
12
+System.out.println("Factorial of entered number is: "+factorial);
13
+}
14
+static int fact(int n)
15
+{
16
+int output;
17
+if(n==1){
18
+return 1;
19
20
+//Recursion: Function calling itself!!
21
+output = fact(n-1)* n;
22
+return output;
23
24
0 commit comments