Created
April 10, 2013 23:34
-
-
Save chikoski/5359372 to your computer and use it in GitHub Desktop.
フィボナッチ数の計算
This file contains hidden or 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 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