[Tutor] LCM

Jacob Bender benderjacob44 at gmail.com
Thu Oct 21 01:30:32 CEST 2010


  Hello all,

I was wondering if you could please help me with an issue I'm having 
with my program. I'm not fond of LCM(Least Common Multiples), and I 
decided to make a program that deals with them. Here's the code:

thing = raw_input("What is the first number?\n\n")

thing2 = raw_input("What is the second number?\n\n")

int(thing)
int(thing2)

x = 1

thing3 = x/thing
thing4 = thing2/x

def calc():
     while True:

         if isinstance(thing3, int) == True:
             if isinstance(thing4, int)== True:
                 print "The LCM is"
                 print x
                 raw_input()
                 break
             else:
                 x + 1
                 calc()


         else:
             x + 1
             calc()

calc()

The only problem is that when I tell it that thing3 = x/thing it gives 
an error. Here it is:

Traceback (most recent call last):
   File "C:/Documents and Settings/Family/My Documents/LCM.py", line 10, 
in <module>
     thing3 = x/thing
TypeError: unsupported operand type(s) for /: 'int' and 'str'

Same with thing4...

Can you please help! Thanks in advance...





More information about the Tutor mailing list