Python Online Compiler
Example: GCD of Two Numbers in Python using While loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# GCD of Two Numbers in Python using While loop p, q = None, None # To store the two positive numbers print ("TWO POSITIVE INTEGER NUMBERS::") p = int (input ()) q = int (input ()) # It will calculate the GCD while p != q: if p > q: p -= q else: q -= p # It will print the final output print ("\nGCD =", p)
160 70
Output
Clear
ADVERTISEMENTS