Project Euler 5 - Smallest multiple
Project Euler 5 - Smallest multiple
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?
Official link: https://projecteuler.net/problem=5
Thought Process
Thought Process
We can take the biggest prime factors from 11-20 and multiply them
20 = 2^2 * 5
19 = 19
18 = 2 * 3^2
17 = 17
16 = 2^4
15 = 3 * 5
14 = 2 * 7
13 = 13
11 = 11
Answer = 11 * 13 * 7 * 5 * 2^4 * 17 * 3^2 * 19
Or we can continuously take the lcm, for example a = lcm(20,19), b = lcm(a,18), etc
Interactive Code
Interactive Code
Enter a number (yourinput)
Code will output the lcm from 1 till yourinput