Skip to content

Commit 4279462

Browse files
committed
#6 - Java
1 parent 5014967 commit 4279462

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class hernanR {
2+
public static void main(String[] args) {
3+
recursividad(100);
4+
System.out.println(factorial(5));
5+
}
6+
7+
public static void recursividad(int num) {
8+
if (num >= 0) {
9+
System.out.println(num);
10+
recursividad(num - 1);
11+
}
12+
}
13+
14+
public static int factorial(int num) {
15+
if (num == 0) {
16+
return 1;
17+
} else {
18+
return num * factorial(num - 1);
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)