Академический Документы
Профессиональный Документы
Культура Документы
Aim:
Algorithm:
Code:
******************************************************************************
Algorithm:
Code:
i = 1
while(i <= a and i <= b):
if(a % i == 0 and b % i == 0):
gcd = i
i = i + 1
# Function to return
# LCM of two numbers
def findLCM(a, b):
lar = max(a, b)
small = min(a, b)
i = lar
while(1) :
if (i % small == 0):
return i
i += lar
# Driver Code
a = 5
b = 7
print("LCM of " , a , " and ",
b , " is " ,
findLCM(a, b), sep = "")
*********************************************************************************************
ARMSTRONG NUMBER
Code:
# Python program to check if the number provided by the user is an Armstrong
number or not
# initialize sum
sum = 0