Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn fib(n: u32) -> u32 {
- if n == 0 { // Base condition 1
- 0
- } else if n == 1 { // Base condition 2
- 1
- } else {
- fib(n - 1) + fib(n - 2)
- }
- }
- fn main() {
- for i in 0..11 {
- print!("{} ", fib(i));
- }
- println!("");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement