Smallest positive number evenly divisible by all integers 1 to 20 without a remainder.
Lower limit is the product of all primes lower than 20. This is our tentative answer.
Determine which numbers in the range can not be divided evenly into this tentative answer. Determine which of those numbers is the smallest, and what the smallest prime factor that number have.
Multiply the tentative answer by that prime factor - we have a new tenative answer.
Repeat until all numbers 1 to 20 divide the tentative answer evenly.
library(numbers)
answer <- function(x){
lower <- prod(numbers::Primes(1,x))
range <- 1:x
while(!all(lower %% range == 0)){
kand <- min(range[lower %% range != 0])
kand <- min(primeFactors(kand))
lower <- lower * kand
}
lower
}
answer <- answer(20)