Get Time
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
Finding the Smallest Multiple of a range of numbers--Program keeps processing forever | Reply
Hello Coders,
I am a new member in this member, so forgive me if I'm posting in the wrong thread or if I missed a point anywhere.

I am trying to find the soln to the following problem:

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?

I am trying to solve this using Python 3.6.1 by creating a function and using the following code:

#a, i and n are used for looping
def smallest_multiple(x):
for i in range(1,x+1):
while a in range (1,i+1):
if a%i==0:
for n in range(0,len(multiplier_list)):
print (num)
x=int(input("Enter a positive integer:\n"))

I am still quite new in Python and I have just started learning 'Classes' in it.
Any idea as to why the program keeps running forever and other ways(however simple or complex) will be extremely appreciated.