Write a python function to compute the lcm of two numbers


Topic: Write a python function to compute the lcm of two numbers

Solution

 def lcm(x, y):
   if x > y:
       greater = x
   else:
       greater = y
   while(True):
       if((greater % x == 0) and (greater % y == 0)):
           lcm = greater
           break
       greater += 1
   return lcm
   
 # write a python function to check whether the number is an Armstrong number or not
 def Armstrong(num):
    sum = 0
    temp = num
    while temp > 0:
       digit = temp % 10
       sum += digit ** 3
       temp //= 10
   
    if num == sum:
       print(num,"is an Armstrong number")
    else:
       print(num,"is not an Armstrong number")
       
 # write a python function to check whether the string is a palindrome or not
 def palindrome(my_str):
    my_str = my_str.casefold()
    rev_str = reversed(my_str)
    if list(my_str) == list(rev_str):
       print("The string is a palindrome.")
    else:
       print("The string is not a palindrome.")
 



List all Python Programs