DEV Community

Discussion on: Project Euler #6 - Sum Square Difference

Collapse
 
jay profile image
Jay

Rust Solution: Playground

fn main() {
    println!("{}", get_difference(100));
}

fn get_difference(end: usize) -> u32 {
    ((1..=end).sum::<usize>().pow(2) - (1..=end).map(|n| n.pow(2)).sum::<usize>()) as u32
}