Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f6c2214

Browse files
algorithms/src/main/java/ivanmarkovic/algorithms/recursion/Factorial.java
1 parent b2a7fe1 commit f6c2214

File tree

1 file changed

+19
-0
lines changed
  • algorithms/src/main/java/ivanmarkovic/algorithms/recursion

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package ivanmarkovic.algorithms.recursion;
2+
3+
public class Factorial {
4+
5+
public static void main(String args[]) {
6+
7+
for(int i = 0; i <= 6; i++)
8+
System.out.println("Factorial of " + i + " is " + factorialRecursive(i));
9+
}
10+
11+
public static int factorialRecursive(int n) {
12+
if(n <= 1)
13+
return 1;
14+
else
15+
return n * factorialRecursive(n - 1);
16+
17+
}
18+
19+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /