Program To Calculate LCM Of Two Numbers | Python Tutorials

preview_player
Показать описание
In this Python Programming video tutorial you will learn to write program to calculate LCM of two numbers in detail.

In arithmetic and number theory, the least common multiple, lowest common multiple, or smallest common multiple of two integers a and b, usually denoted by lcm, is the smallest positive integer that is divisible by both a and b.

GCD Program

#LCM #PythonPrograms

For more free tutorials on computer programming
Рекомендации по теме
Комментарии
Автор

Respected mam, you don't know that how much you are helping to the students like me.ThankYou mam.

alokik
Автор

I did it this way only a little change is there i hope you like it:

n1 = int(input('Enter first number: '))
n2 = int(input('Enter second number: '))

a = 1

if n1>n2:
l = n1
else:
l = n2

while True:
if n1>0:
z = n1*a
a+=1
if z%n2 == 0:
print(z, ' is the LCM.')
break

else:
print(0)

ashmitsrivastava
Автор

Another way to solve this problem :)
Btw your explanation was pretty good :)
THE CODE:
def lcm(n1, n2):
value = max(n1, n2)
n = 1
while True:
ans = value * n
if ans % n1 == 0 and ans % n2 == 0:
print("The lcm of the program is ", ans, ".")
break
n += 1
n1 = int(input())
n2 = int(input())
lcm(n1, n2)

moviemania
Автор

Thank you so much mam for making us easily to understand the logic 👏👏

jahnavi.m
Автор

This is for the people in a time crunch :

def Compute_LCM(n1, n2):
if n1>n2:
higher = n1
else:
higher = n2
value = higher
while True:
if higher%n1==0 and higher%n2==0:
print("LCM of", n1, "and", n2, "is", higher)
break
else:
higher = higher+value

n1=int(input("No.1 please:"))
n2=int(input("No. 2 please:"))
Compute_LCM(n1, n2)

priyanshkhare
Автор

actually i like these lectures..
my kind request you to create an telegram channel so we will get updates sa possible!!

bhubeshsr
Автор

ma'am please make python tutorials for tcs nqt coding section evryone is covering that topic using c, c++ no one's considering python, though python is the best language, i found this channel best for python ✌🏻💯

yourvibe
Автор

amazing explaination, thank you so much!

vabphogat
Автор

this video is very helpful for us thank you so much mam :) and i request you to do a video on how to print pythogoras triplets in range of n numbers

rrrrr
Автор

Respected mam, my cognizant exam is scheduled after 15days and and I have also applied for TCS NQT. I want to crack both of the companies. Please guide me mam.. please 😅

alokik
Автор

Mam please make a video on the program to find the smallest of 10 numbers entered, a sum of the digits of the smallest number, if it is an integer

ruchigupta
Автор

Mam you are superb.Great respect from class 11 Tint Tots public school.

anuragjain
Автор

Glad to see your current video please drop the video on Linkedlist singly or double linked list

SumitSinghzz
Автор

mam please keep uploading videos like this it helped me a lot ♥

_ShivamGupta
Автор

I like the way of teaching....thank you!
expecting more videos from u

prabathkotti
Автор

if you ever thought this was tough
try this code....
import math
print(math.lcm(x, y))

ritviksourab
Автор

This is your first video I saw and like, subscribed Because I like the way you teach us
superb
Keep it up Sister😊
👍

rameenumer
Автор

Hi Amul! Is it me or did your channel grow A LOT?? :) :)

BrendanMetcalfe
Автор

factors of n2 will always get 0 as modulo when performing : higher%n2 == so its better to exclude this condition.

Leo-srq
Автор

When I put else block straight to while loop, it is not providing output. But in your another video, you have given else block straight to while loop. Can u explain mam

gayathri--is