Skip to content

Instantly share code, notes, and snippets.

@MatejLach
Created July 21, 2014 13:58
Show Gist options
  • Save MatejLach/81e0c0ec301eb6386d51 to your computer and use it in GitHub Desktop.
Save MatejLach/81e0c0ec301eb6386d51 to your computer and use it in GitHub Desktop.
Demonstrates a case where one has to use mutable variables in Rust
// 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