0% found this document useful (0 votes)
20 views2 pages

LCM and HCF

Uploaded by

kavyat438
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

LCM and HCF

Uploaded by

kavyat438
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PRACTICAL-6

 #NAME=KAVYA THAKUR
 #ROLL NO= 245583589
 #course=bsc electronics
 #date=9/10/2024
 #AIM= lcm of two numbers in python

#AIM=LCM of two numbers in python

a=int(input("enter your 1st number for lcm:" ))

b=int(input("enter your 2nd number for lcm:" ))

hcf=1

for i in range(2,a+1):

if(a%i==0 and b%i==0):

hcf=i

print("first number is" ,a)

print("second number is" ,b)

LCM=int((a*b)/(hcf))

print("LCM of two number is" ,LCM)

OUTPUT
======= RESTART: C:/Users/HP/AppData/Local/Programs/Python/Python311/K.py
======

enter your 1st number for lcm:

======= RESTART: C:/Users/HP/AppData/Local/Programs/Python/Python311/K.py


======

enter your 1st number for lcm:7

enter your 2nd number for lcm:8

first number is 7

second number is 8
LCM of two number is 56

#AIM=HCF of two numbers in python


a=int(input("enter your 1st number for hcf:" ))

b=int(input("enter your 2nd number for hcf:" ))

hcf=1

for i in range(2,a+1):

if(a%i==0 and b%i==0):

hcf=i

print("first number is" ,a)

print("second number is" ,b)

print("HCF of two number is" ,hcf)

OUTPUT
======= RESTART: C:/Users/HP/AppData/Local/Programs/Python/Python311/K.py
======

enter your 1st number for hcf:16

enter your 2nd number for hcf:14

first number is 16

second number is 14

HCF of two number is 2

You might also like