Python Online Compiler
Example: GCD of Two Numbers in Python using For loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# GCD of Two Numbers in Python using For 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 for i in range (1, p + 1): if i <= q: if p % i == 0 and q % i == 0: g = i # It will print the final output print ("\nGCD =", p)
160 70
Output
Clear
ADVERTISEMENTS