Skip to main content

Command Palette

Search for a command to run...

Project Euler Problem 5

Updated
1 min read

' https://projecteuler.net/problem=5
' 232792560

sub main()
' 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 is evenly divisible by all of the numbers from 1 to 20?


num = 20

while not done
    divs = [ 19,18,17,16,15,14,13,12,11 ]

    for i = 0 to divs.count()-1
        if not isDivisable( num, divs[i] )
            exit for
        end if
    end for

    if i = divs.count() 
        exit while 
    end if

    num = num + 20

end while

print "Num: "; num

end sub


function isDivisable( number, div ) as boolean
    return (number mod div) = 0
end function