Python Online Compiler
Example: Python Program to Find LCM of Two Numbers using For loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python Program to Find LCM of Two Numbers using For loop p, q, x, g = 0, 0, 0, 0 # p & q - To store the two positive numbers # x - To store the LCM number # g - To store the GCD print ("-----Enter the two positive integer numbers-----") p = int (input ()) q = int (input ()) for i in range (1, p + 1): if i <= q: if p % i == 0 and q % i == 0: g = i x = (p * q) / g print ("\nThe LCM of two positive numbers ", p, " & ", q, " is ", x, ".")
130 170
Output
Clear
ADVERTISEMENTS