Skip to content

Instantly share code, notes, and snippets.

@svc-user
Created April 6, 2017 08:32
Show Gist options
  • Save svc-user/1055ac8f10f84c437188328eab89233a to your computer and use it in GitHub Desktop.
Save svc-user/1055ac8f10f84c437188328eab89233a to your computer and use it in GitHub Desktop.
Find the first fibonnaci numbers up to 100 million
#import "fmt.odin";
main :: proc() {
#label loop
for i := 1; ; i++ {
f := fib(i);
fmt.println(f);
if f > 100_000_000 {
break loop;
}
continue loop;
}
}
fib :: proc(n: int) -> int {
if n < 1 {
return 0;
}
else if n <= 2 {
return 1;
}
else {
return fib(n - 1) + fib(n - 2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment