Skip to content

Commit 4795f07

Browse files
author
Gerardo Medellin
committed
#6 - Go
1 parent 125466f commit 4795f07

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
//Dificultad extra
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

Comments
 (0)