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.
1 parent 7f1df0c commit fa3da3dCopy full SHA for fa3da3d
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