JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums TopCoder Cookbook General TopCoder Cookbook Discussion Finding the Smallest Multiple of a range of numbers--Program keeps processing forever
 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 loopingdef smallest_multiple(x): num=1 multiplier_list=[] for i in range(1,x+1): a=1 while a in range (1,i+1): if a%i==0: multiplier_list.append(a) for n in range(0,len(multiplier_list)): num=num*int(multiplier_list[n]) print (num)x=int(input("Enter a positive integer:\n"))smallest_multiple(x)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.
 Forums TopCoder Cookbook General TopCoder Cookbook Discussion Finding the Smallest Multiple of a range of numbers--Program keeps processing forever Previous Thread  |  Next Thread