Question: I need help with my python code. my output is saying None seconds for the prime and successive. from stopwatch import stopwatch def backward (

I need help with my python code. my output is saying None seconds for the prime and successive. from stopwatch import stopwatch
def backward(A,B):
if A < B:
T = A
else:
T = B
while True:
if B % T !=0:
T = T -1
elif A % T !=0:
T = T -1
else:
return T
def prime(A, B):
def numbers(N):
p =2
nums =[]
while N >= p*p:
if (N % p)==0:
nums.append(p)
N = N // p
else:
p = p +1
nums.append(int(N))
return nums
Anum = numbers(A)
Bnum = numbers(B)
gcd =1
if len(Anum)< len(Bnum):
for Adom in Anums:
gcd = gcd * Adom
Bnum.remove(Adom)
else:
for Bdom in Bnumbers:
gcd = gcd * Bdom
Anum.remove(Bdom)
return gcd
def successive(A,B):
if A ==0:
return B
if B ==0:
return A
while (A !=0) and (B !=0):
if A > B:
A = A - B
else: B = B - A
def main():
A=int(input("Please enter the first integer: "))
B=int(input("Please enter the second integer: "))
seconds = stopwatch()
print("The Backwards For Loop: {} seconds".format(backward(A,B),seconds.lap()))
print("The Prime Factorization: {} seconds".format(prime(A,B),seconds.lap()))
print("The Successive: {} seconds".format(successive(A,B),seconds.lap()))
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!