Skip to content

Instantly share code, notes, and snippets.

@mdespuits mdespuits/fib.rs
Last active Dec 15, 2015

Embed
What would you like to do?
My first Rust program
// My first Rust program
// Simply outputs fibbonaci numbers from 20 to 0
use core::task::spawn;
fn fib(number: int) -> int {
if number > 1 {
return fib(number - 1) + fib(number - 2);
} else {
return number;
}
}
fn main() {
for int::range(0, 20) |num| {
do spawn {
io::println(fmt!("Fibbonaci of %d is: %d\n", num, fib(num)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.