Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fold Product

Use .fold() to calculate the product of all numbers in vec![2, 3, 4]. Start with 1 as the initial value.

Expected output:

text
Product: 24

Hints:

  • .fold(1, |acc, x| acc * x) starts with 1 and multiplies each item
  • acc is the accumulator (running total), x is the current item
rust
fn main() {
}