Skip to content

Commit b8ae6f5

Browse files
committed
02_basic_calculator/07_for
1 parent 9417c9c commit b8ae6f5

File tree

1 file changed

+7
-1
lines changed
  • exercises/02_basic_calculator/07_for/src

1 file changed

+7
-1
lines changed

exercises/02_basic_calculator/07_for/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// Rewrite the factorial function using a `for` loop.
22
pub fn factorial(n: u32) -> u32 {
3-
todo!()
3+
let mut ret: u32 = 1;
4+
5+
for i in 2..(n + 1) {
6+
ret *= i;
7+
}
8+
9+
ret
410
}
511

612
#[cfg(test)]

0 commit comments

Comments
 (0)