Skip to content

Commit e92df12

Browse files
authored
#6 - C++
1 parent 1623301 commit e92df12

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
3+
void PrintNumbers(int number)
4+
{
5+
if(number >= 0)
6+
{
7+
printf("%d\n", number);
8+
PrintNumbers(number-1);
9+
}
10+
11+
return;
12+
}
13+
14+
int Factorial(int number)
15+
{
16+
if(number==0)
17+
return 1;
18+
else
19+
return (number * Factorial(number-1));
20+
}
21+
22+
int Fibonacci(int number)
23+
{
24+
if(number == 0)
25+
return 0;
26+
else if(number == 1)
27+
return 1;
28+
else
29+
return ((Fibonacci(number-1) + Fibonacci(number-2)));
30+
}
31+
32+
int main()
33+
{
34+
PrintNumbers(100);
35+
printf("\n5! = %d\n\n", Factorial(5));
36+
37+
for(int i=1; i<11; i++)
38+
{
39+
printf("Valor de la %d%c posicion en la sucesion de Fibonacci: %d\n", i, 167, Fibonacci(i));
40+
}
41+
42+
return 0;
43+
}

0 commit comments

Comments
 (0)