Skip to content

Instantly share code, notes, and snippets.

@mdespuits
Last active December 15, 2015 14:09
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 mdespuits/5272441 to your computer and use it in GitHub Desktop.
Save mdespuits/5272441 to your computer and use it in GitHub Desktop.
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