Skip to content

Commit b1454df

Browse files
authored
Merge pull request mouredev#4855 from julian98789/patch-9
#6 - java
2 parents 694e48b + bfba784 commit b1454df

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
public class reto_6 {
3+
4+
public static void main(String[] args) {
5+
6+
numRecursivo(0);
7+
System.out.println("\n **********************");
8+
int factorial = factorial(5);
9+
10+
System.out.println("Factorial: " + factorial +"\n");
11+
12+
int Fibonacci = Fibonacci(5);
13+
14+
System.out.println("El numero es: " + Fibonacci);
15+
}
16+
17+
public static void numRecursivo( int n){
18+
19+
if (n > 100) {
20+
return;
21+
}
22+
System.out.println(n);
23+
numRecursivo(n+1);
24+
25+
26+
}
27+
public static int factorial( int n){
28+
29+
if (n == 0 || n == 1) {
30+
return 1;
31+
}
32+
return n * factorial(n - 1);
33+
}
34+
35+
public static int Fibonacci ( int n){
36+
37+
if (n <= 1) {
38+
return n;
39+
}else{
40+
return (Fibonacci( n - 1) + Fibonacci( n- 2));
41+
}
42+
}
43+
}
44+

0 commit comments

Comments
 (0)