finish iterators4 exercise
This commit is contained in:
parent
e63c871147
commit
2a9bd74176
|
@ -1,7 +1,5 @@
|
|||
// iterators4.rs
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
pub fn factorial(num: u64) -> u64 {
|
||||
// Complete this function to return the factorial of num
|
||||
// Do not use:
|
||||
|
@ -12,6 +10,7 @@ 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)]
|
||||
|
|
Loading…
Reference in a new issue