Created
April 6, 2017 08:32
-
-
Save svc-user/1055ac8f10f84c437188328eab89233a to your computer and use it in GitHub Desktop.
Find the first fibonnaci numbers up to 100 million
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
#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