- #1
newb
- 10
- 0
How can you go about finding the smallest number (x) that is evenly divisible by a set of numbers from 1 to n?
For example:
If n = 3, x=6
n = 4, x=12
n=5, x=60
n=6, x=60
This is easy to do when n is a small number, however how would one go about finding the answer if n=20 for example?
I have written a program that tries to brute force the answer, but I'm almost certain there's a much more elegant way to do it. Any advice?
For example:
If n = 3, x=6
n = 4, x=12
n=5, x=60
n=6, x=60
This is easy to do when n is a small number, however how would one go about finding the answer if n=20 for example?
I have written a program that tries to brute force the answer, but I'm almost certain there's a much more elegant way to do it. Any advice?