Easy Level Python Interview Coding Questions.

Avinash
Jan 8, 2022

--

How to find out the Greatest Common Divisor(GCD) using python?

Algorithm for GCD:

1: Initialize the two integers A and B and make sure they are positive.

2: Take max of those and store them in a separate variable.

3: Now initialize an empty list.

4: Now run a for loop and append all the values which are dividing both A and B.

5: Now print the max value of the list. Which is our GCD.

CODE:

Thank you !!

--

--

Avinash
Avinash

Written by Avinash

Currently Pursuing my Post graduation at Manipal University. LinkedIn Profile: www.linkedin.com/in/avinash-kumar-60396710b

No responses yet