Skip to content

Instantly share code, notes, and snippets.

@sleibrock
Created April 19, 2017 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sleibrock/c6e0c9514ec38fe8e8cea57a009503aa to your computer and use it in GitHub Desktop.
Save sleibrock/c6e0c9514ec38fe8e8cea57a009503aa to your computer and use it in GitHub Desktop.
Dumb Sum of Multiples of 3 or 5 under N
fn solution(num: i32) -> i32 {
let mut acc = 0;
for x in 0..num {
match (x % 3, x % 5) {
(0, 0) => acc += x,
(0, _) => acc += x,
(_, 0) => acc += x,
_ => {}
}
}
return acc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment