Skip to content

Instantly share code, notes, and snippets.

@kinoshita-lab
Created September 12, 2020 07:22
Show Gist options
  • Save kinoshita-lab/dd855a956c8870dfaf7a9601553586e4 to your computer and use it in GitHub Desktop.
Save kinoshita-lab/dd855a956c8870dfaf7a9601553586e4 to your computer and use it in GitHub Desktop.
project euler problem 6
fn main() {
let upper = 100;
let sum_of_squares = (0..upper).fold(0, |acc, i| acc + (i * i));
let sum = (0..upper).fold(0, |acc, i| acc + i);
let square_of_sum = sum * sum;
let difference = square_of_sum - sum_of_squares;
println!("{:?}", difference);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment