There was an error while loading. Please reload this page.
1 parent f12261b commit 4bb9f32Copy full SHA for 4bb9f32
src/com/sanket/recursion/Factorial.java
@@ -0,0 +1,35 @@
1
+/**
2
+ *
3
+ */
4
+package com.sanket.recursion;
5
+
6
7
+ * @author Sanket Gupta
8
9
10
+public class Factorial {
11
12
13
+ * @param args
14
15
+public static void main(String[] args) {
16
17
+int i = 10; //Integer.parseInt(args[0]);
18
+int output = factorial(i);
19
+System.out.println(i+"! = "+output);
20
21
+}
22
23
24
25
+ * @param i
26
+ * @return
27
28
+public static int factorial(int i) {
29
+if(i>1)//break condition
30
+return i * factorial(i -1);//recursion
31
+else
32
+return 1;
33
34
35
0 commit comments