Created
June 11, 2024 18:26
-
-
Save bilalobe/eda7f4eb97a16540cba8509381bf14fa to your computer and use it in GitHub Desktop.
lake mead marina boat fire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This approach uses a loop to compute the Fibonacci sequence without recursion @workspace