We're a place where coders share, stay up-to-date and grow their careers.
Rust Solution Playground
fn main() { println!("{}", get_number(1, 20)) } fn get_number(start: usize, end: usize) -> u32 { (start..end).fold(1_u32, |acc, n| lcm(acc, n as u32)) } fn lcm(a: u32, b: u32) -> u32 { (a * b) / gcd(a, b) } fn gcd(a: u32, b: u32) -> u32 { if b == 0 { a } else { gcd(b, a % b) } }
Rust Solution Playground