Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created April 10, 2013 23:34
Show Gist options
  • Save chikoski/5359372 to your computer and use it in GitHub Desktop.
Save chikoski/5359372 to your computer and use it in GitHub Desktop.
フィボナッチ数の計算
fn fib(n:int) -> int{
match n{
0 | 1 => { 1 },
_ => { fib(n-1) + fib(n-2) }
}
}
fn main(){
let mut n = 0;
let max = 10;
while n <= max{
io::println(fmt!("fib(%2d) = %?", n, fib(n)));
n = n + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment