diff --git a/functional_programming/ch01/fibonacci.go b/functional_programming/ch01/fibonacci.go new file mode 100644 index 0000000..fa08d94 --- /dev/null +++ b/functional_programming/ch01/fibonacci.go @@ -0,0 +1,18 @@ +package main + +import "fmt" + +func Fibonacci(x int) int { + if x == 0 { + return 0 + } else if x <= 2 { + return 1 + } else { + return Fibonacci(x-2) + Fibonacci(x-1) + } +} + +func main() { + fib := Fibonacci + fmt.Printf("%vn", fib(50)) +}