Python Online Compiler
Example: Python Program to Find LCM of Two Numbers using While loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python Program to Find LCM of Two Numbers using While loop p, q, x = None, None, None # p & q - To store the two positive numbers # x - To store the LCM number print ("-----Enter the two positive integer numbers-----") p = int (input ()) q = int (input ()) x = p if p > q else q while True: if x % p == 0 and x % q == 0: print ("\nThe LCM of the ", p, " and ", q, " numbers is ", x, ".") break x += 1
120 140
Output
Clear
ADVERTISEMENTS