We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 125466f commit 4795f07Copy full SHA for 4795f07
Roadmap/06 - RECURSIVIDAD/go/thegera4.go
@@ -0,0 +1,28 @@
1
+package main
2
+
3
+import "fmt"
4
5
+func main() {
6
+ fmt.Println(cuentaRegresiva(100))
7
+ fmt.Println(factorial(5)) //120
8
+ fmt.Println(fibonacci(10)) //55
9
+}
10
11
+func cuentaRegresiva(number int) int{
12
+ if number == 0 { return 0 }
13
+ fmt.Println(number)
14
+ return cuentaRegresiva(number - 1)
15
16
17
+//Dificultad extra
18
+func factorial(number int) int{
19
+ if number == 0 { return 1 }
20
+ return number * factorial(number - 1)
21
22
23
24
+func fibonacci(position int) int{
25
+ if position == 0 { return 0 }
26
+ if position == 1 { return 1 }
27
+ return fibonacci(position - 1) + fibonacci(position - 2)
28
0 commit comments