This commit is contained in:
2024-04-19 13:20:35 -04:00
parent c14f32b752
commit c5b8b068ea
2 changed files with 8 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
// Execute `rustlings hint iterators4` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
use std::collections::btree_map::Range;
pub fn factorial(num: u64) -> u64 {
// Complete this function to return the factorial of num
@@ -15,6 +15,8 @@ pub fn factorial(num: u64) -> u64 {
// For an extra challenge, don't use:
// - recursion
// Execute `rustlings hint iterators4` for hints.
(1..num + 1).into_iter().fold(1, |acc, x| acc * x)
}
#[cfg(test)]