Created
April 19, 2017 18:30
-
-
Save sleibrock/c6e0c9514ec38fe8e8cea57a009503aa to your computer and use it in GitHub Desktop.
Dumb Sum of Multiples of 3 or 5 under N
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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