Simplify 'product' factorial example
This commit is contained in:
parent
d10680818b
commit
d808f938bc
1 changed files with 1 additions and 1 deletions
|
@ -2358,7 +2358,7 @@ pub trait Iterator {
|
|||
///
|
||||
/// ```
|
||||
/// fn factorial(n: u32) -> u32 {
|
||||
/// (1..).take_while(|&i| i <= n).product()
|
||||
/// (1..=n).product()
|
||||
/// }
|
||||
/// assert_eq!(factorial(0), 1);
|
||||
/// assert_eq!(factorial(1), 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue