Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi there, I need help in this coding. Any idea how to add a counter to count the number of times the program runs to

Hi there, I need help in this coding. Any idea how to add a counter to count the number of times the program runs to get it's GCD?

This program is a GCD algorithm.

a = int(input("Enter first number : "))

b= int( input("Enter second number : "))

def RecursionGCD(a,b,count=0):

if(b==0): #base

c=A%B;

A=B;

B=c;

count+=1;

return a #case

else:

return RecursionGCD(b,a%b) #recursion

a = int(input("Enter first number : "))

b= int( input("Enter second number : "))

# prints results

print ("The gcd of the 2 numbers is : ",end="")

print (RecursionGCD(a,b))

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago