Created
July 21, 2014 13:58
-
-
Save MatejLach/81e0c0ec301eb6386d51 to your computer and use it in GitHub Desktop.
Demonstrates a case where one has to use mutable variables in Rust
This file contains hidden or 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
// Solution to Project Euler problem 1, | |
// https://projecteuler.net/problem=1 | |
fn main() { | |
let (i, result) = (0i, 0i); | |
while i < 1000 { | |
if i%3 == 0 || i%5 == 0 { result += i } | |
i += 1 | |
} | |
println!("{}", result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment