Python Program For LCM of 2 numbers

Task

To find LCM of 2 numbers

Approach

  • Read two input numbers using input().
  • Find the minimum of 2 numbers, using min() function and store the value in numbers_min variable.
  • Now run a while loop and check whether both numbers are divisible by the numbers_min variable which we got in the previous step.
    • if both numbers are divisible by numbers_min print the value as LCM and break the loop
    • if not, increment numbers_min value and continue while loop.

Program

num1 = int(input("Enter first number: \t"))
num2 = int(input("Enter second number: \t"))
 
numbers_min = min(num1, num2)
 
while(1):
    if(numbers_min % num1 == 0 and numbers_min % num2 == 0):
        print("LCM of two number is: ", numbers_min)
        break
    numbers_min += 1

OUTPUT:


1 comment

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...