Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

lcm in python

def lcm(x, y):
   if x > y:
       greater = x
  else:
       greater = y

  while(True):
       if((greater % x == 0) and (greater % y == 0)):
           lcm = greater
           break
        greater += 1

  return lcm

num1 =int (input("enter the first nummber: "))
num2 = int (input("enter the second number: "))

print("The L.C.M. is",lcm(num1, num2))
Comment

python find lcm

def lcm(a, b):
        i = 1
        if a > b:
                c = a
                d = b
        else:
                c = b
                d = a
        while True:
                if ((c * i) / d).is_integer():
                        return c * i
                i += 1;
Comment

PREVIOUS NEXT
Code Example
Python :: python wsgi 
Python :: how to sort nested list in python 
Python :: python round function example 
Python :: numpy split 
Python :: text to speech program in python 
Python :: installing python 3 to linux 
Python :: is_integer python 
Python :: if then else python 
Python :: update all modules python 
Python :: how to read a excel file in python 
Python :: how to replace zero value in python dataframe 
Python :: random.choices without repetition 
Python :: add dataframe column to set 
Python :: pip for python 
Python :: python class variables 
Python :: fill na with average pandas 
Python :: python self usage 
Python :: initialize variable python 
Python :: iterating over lines in a file 
Python :: pandas add prefix to column names 
Python :: python boto3 put_object to s3 
Python :: csv to txt code pandas 
Python :: excelwriter python 
Python :: python include file 
Python :: pytorch get tensor dimension 
Python :: sort dict based on other list 
Python :: scipy cdf example 
Python :: selenium python element id 
Python :: google codelabs 
Python :: how to use visualize_runtimes 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =