Sum 1 to N
Use a for loop to add up all the numbers from 1 to 100 and print the result.
Expected output:
text
Sum: 5050
Hints:
- Create a
let mut sum = 0;variable before the loop - Use
for i in 1..=100to loop through all the numbers - Add each number to
suminside the loop - Print the result after the loop with
println!("Sum: {}", sum);
rust
fn main() {
}