Skip to content

Instantly share code, notes, and snippets.

@qwercik
Last active January 11, 2018 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qwercik/d27a2bf3cd0c38446ac71760930cc81a to your computer and use it in GitHub Desktop.
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)
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