Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

=+(16.32) 81(w) for w A and 0 Answered: 1 week ago

Answered: 1 week ago

Question

1. How might volunteering help the employer and the employee?

Answered: 1 week ago