Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Sum Numbers

Use a while loop to add up all the numbers from 1 to 10, then print the result.

Expected output:

text
Sum: 55

Hints:

  • You'll need two mutable variables: one for the counter and one for the total
  • Start with let mut sum = 0; and let mut i = 1;
  • Add i to sum each time through the loop
  • Print the sum after the loop using println!("Sum: {}", sum);
rust
fn main() {
}