Skip to content

Instantly share code, notes, and snippets.

@servusdei2018
Created February 6, 2021 02:06
Show Gist options
  • Save servusdei2018/5eb825d678a71f1458141b1305d743f9 to your computer and use it in GitHub Desktop.
Save servusdei2018/5eb825d678a71f1458141b1305d743f9 to your computer and use it in GitHub Desktop.
Fast Fibonacci
package main
import (
"flag"
"fmt"
)
var (
N uint64
)
func init() {
flag.Uint64Var(&N, "n", 3, "nth fibonacci number to find")
flag.Parse()
}
// Fastest fibonacci ever.
func fib(n uint64) uint64 {var a,b,c uint64;a=1;b=1;for i:=uint64(3);i<=n;i++{c=a+b;a=b;b=c};return b}
func main() {
fmt.Println(fib(N))
}
@servusdei2018
Copy link
Author

I challenge any Go dev to make a faster fibonacci implementation :)

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