Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compution
#1
Good evening everyone, i m trying to compute GCD and LCM of n numbers and i can only do GCD and LCM for two integer numbers. I need your help and/or direction on this problem.
while True:
    x=int(input('Enter a number:'))
    if x==0:
        break
    else: 
        y=int(input('Enter a number:'))
        temp1= x
        temp2=y
        while temp2 !=0:
            t= temp2
            temp2=temp1%temp2
            temp1= t
        gcd = temp1
        lcm = (x*y)/gcd
        print("GCD =",gcd)
        print("LCM =", int(lcm))
Reply


Messages In This Thread
Compution - by lekuru01 - Apr-02-2019, 12:47 AM
RE: Compution - by scidam - Apr-02-2019, 10:17 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020