Created
September 12, 2020 07:22
-
-
Save kinoshita-lab/dd855a956c8870dfaf7a9601553586e4 to your computer and use it in GitHub Desktop.
project euler problem 6
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
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