Skip to content

Commit

Permalink
14.4 funcoes recursivas
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruteski committed Mar 27, 2024
1 parent 63ddae6 commit 14377af
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 14-funcoes_avacadas/14.4-funcoes_recursivas/funcao_recursiva.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import "fmt"

func fibonacci(posicao uint) uint {
if posicao <= 1 {
return posicao
}

return fibonacci(posicao-2) + fibonacci(posicao-1)
}

func main() {
posicao := uint(20)

for i := uint(0); i < posicao; i++ {
fmt.Println(fibonacci(i))
}

fmt.Println(fibonacci(posicao))
}

0 comments on commit 14377af

Please sign in to comment.