new file: algo/fibonacci.go

This commit is contained in:
Acid
2026-06-08 19:45:37 -04:00
parent 4ec06215fb
commit 857189c4f8
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
- [x] Kadane's Algorithm
- [x] Euclidean gcd
- [ ] Fibonacci
- [x] Fibonacci
- [ ] Modular Arithmetic
- [ ] Sieve of Eratosthenes
- [ ] BFS Breadth-First Search
+16
View File
@@ -0,0 +1,16 @@
package algo
// Fib() -> fibonacci linear implementation O(n)
func Fib(target int) int {
a := 0
b := 1
if target <= 1 {
return target
}
for a < target {
a, b = b, a+b
}
return a
}