Skip to content

Instantly share code, notes, and snippets.

@bilalobe
Created June 11, 2024 18:26
Show Gist options
  • Save bilalobe/eda7f4eb97a16540cba8509381bf14fa to your computer and use it in GitHub Desktop.
Save bilalobe/eda7f4eb97a16540cba8509381bf14fa to your computer and use it in GitHub Desktop.
lake mead marina boat fire
package main
func fibonacci(n int) int {
a, b := 0, 1
for i := 0; i < n; i++ {
a, b = b, a+b
}
return a
}
func main() {
for i := 0; i < 10; i++ {
fmt.Println(fibonacci(i))
}
}
@bilalobe
Copy link
Author

This approach uses a loop to compute the Fibonacci sequence without recursion @workspace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment