oily-solutions/multiples_of_3_or_5.rs

13 lines
290 B
Rust
Raw Normal View History

2024-11-19 20:47:13 +00:00
fn main() {
let mut multiples: Vec<i32> = vec![];
for num in 0..1000 {
if num % 3 == 0 {
multiples.push(num);
} else if num % 5 == 0 {
multiples.push(num);
}
}
let sum: i32 = multiples.iter().sum();
println!("{}", sum);
}