completed till 06/07

This commit is contained in:
2025-04-01 07:15:32 +05:30
parent 2fa61e7715
commit f980a3b381
7 changed files with 52 additions and 6 deletions

View File

@@ -15,7 +15,11 @@ pub fn fibonacci(n: u32) -> u32 {
//
// Hint: use a `Vec` to memoize the results you have already calculated
// so that you don't have to recalculate them several times.
todo!()
let mut fibNums = vec![0, 1];
for i in 2..=n {
fibNums.push(fibNums[(i - 1) as usize] + fibNums[(i - 2) as usize]);
}
fibNums[(n) as usize]
}
#[cfg(test)]