Loading RustViz Engine...
Calculate ways to climb n steps taking 1 or 2 steps at a time.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
pub fn climb_stairs(n: u32) -> u32 {
let (mut prev2, mut prev1) = (1, 1);
for _ in 2..=n {
let curr = prev1 + prev2;
prev2 = prev1;
prev1 = curr;
}
prev1
}