Last active
December 15, 2015 14:09
-
-
Save mdespuits/5272441 to your computer and use it in GitHub Desktop.
My first Rust program
This file contains 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
// 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