Avatar ·

The more rational implementation of the enforcement algorithm to find the smallest positive number, which is divided into all numbers from 1 to 20

📁 python

There is a problem:

2520 is the smallest number that can be divided into each of the numbers from 1 to 10 without a residue.

Find such a smallest positive number that is divided by all numbers from 1 to 20?

the task of this I decided, having written a poorly optimized algorithm for a complete enumeration of options.

  drawculate =  true  max_number =  20  min_number =  1  current_divisible =  2520  count =  0    While  calculate:   for  i  in   range  ( 2 , max_number +  1 ):   if  current_divisible % I ==  0 :  count + =  1   min_number = current_divisible  else :  count =  0    1    if  count == max_number:  classlate =  false    Print  (min_number)