Kevin Silberberg
  • Home
  • Photos
  • Study

Smallest Multiple

Problem 5

Author

Kevin Silberberg

Published

May 16, 2025

Problem definition

\(2520\) is the smallest number that can be divided by each of the numbers from \(1\) to \(10\) without any remainder.

What is the smallest positive number that can is evenly divisible by all of the numbers from \(1\) to \(20\)?

Solution

function isDivisible(num::Int)
    r::Int = 0
    for i = 1:20
        r = mod(num, i)
        if r != 0
            return false
        end
    end
    return true
end

function main()
    current = 2520
    while !(isDivisible(current))
        current += 1
    end
    current
end
main()
232792560

© Copyright 2025 Kevin Silberberg. Except where otherwise noted, all text and images licensed CC-BY-NC 4.0.