2012-01-14 21:00:59 -06:00
|
|
|
use std;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn fib(n: int) -> int {
|
2012-01-14 21:00:59 -06:00
|
|
|
if n < 2 {
|
|
|
|
ret 1;
|
|
|
|
} else {
|
|
|
|
ret fib(n - 1) + fib(n - 2);
|
|
|
|
}
|
2010-06-23 23:03:09 -05:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:00:59 -06:00
|
|
|
fn main(args: [str]) {
|
|
|
|
let n = if vec::len(args) == 2u {
|
2012-02-22 06:18:15 -06:00
|
|
|
option::get(int::from_str(args[1]))
|
2012-01-14 21:00:59 -06:00
|
|
|
} else {
|
2012-01-14 22:34:00 -06:00
|
|
|
30
|
2012-01-14 21:00:59 -06:00
|
|
|
};
|
2012-03-12 22:04:27 -05:00
|
|
|
io::println(#fmt("%d\n", fib(n)));
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|