Last active
January 11, 2018 19:25
-
-
Save qwercik/d27a2bf3cd0c38446ac71760930cc81a to your computer and use it in GitHub Desktop.
Generator kolejnych elementów ciągu Fibonacciego napisany w języku Rust (rekurencyjnie, mało wydajny algorytm)
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
fn main() { | |
for index in 0..10 { | |
println!("{}", fib(index)); | |
} | |
} | |
fn fib(index: u32) -> u32 { | |
return match index { | |
0 | 1 => 1, | |
_ => fib(index - 1) + fib(index - 2), | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment