You are viewing a single comment's thread. Return to all comments →
RUST:
use std::io; fn main() { let mut input = String::new(); io::stdin().read_line(&mut input).unwrap_or(0); let n = input.trim().parse::<i32>().unwrap_or(0); println!("{}", fibonacci(n)); } fn fibonacci(n: i32) -> i32 { let mut a = 0; let mut b = 1; for _ in 0..n { let temp = a; a = b; b = temp + b; } a }
Seems like cookies are disabled on this browser, please enable them to open this website
Recursion: Fibonacci Numbers
You are viewing a single comment's thread. Return to all comments →
RUST: