Smallest multiple: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
Line 2: Line 2:


;Task:
;Task:
Task desciption is taken from [https://projecteuler.net/problem=5 Project Euler]

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
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?
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

Revision as of 05:45, 21 October 2021

Smallest multiple is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task

Task desciption is taken from Project Euler 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?

Ring

<lang ring> see "working..." + nl see "Smallest multiple is:" + nl n = 0

while true

     n++
     flag = 0
     for m = 1 to 20
         if n % m = 0
            flag += 1
         ok
     next
     if flag = 20
        see "" + n + nl
        exit
     ok

end

see "done..." + nl </lang>

Output:
working...
Smallest multiple is:
232792560
done...