I write two code to compute gcd in python3, but math.gcd is much faster than gcd.↵
↵
Here is my code.↵
`↵
~~~~~↵
Your code here...↵
~~~~~↵
↵
`↵
↵
`````↵
def gcd(a, b):```↵
def gcd(a, b): ↵
↵
while a:↵
↵
a, b = b % a, a↵
↵
return b↵
↵
x, y = map(int, input().split())↵
↵
print(gcd(x, y))↵
↵
```↵
↵
And another code.↵
```↵
import math↵
x, y = map(int, input().split())↵
print(math.gcd(x, y))↵
```↵
![ ](/predownloaded/ef/a7/efa74dfc5aed9d7328d84db38419235300d51e9b.png)↵
↵
What's the implemention of math.gcd?↵
Thanks in advance.↵
↵
↵
Here is my code.↵
Your code here...↵
~~~~~↵
↵
`↵
↵
`````↵
def gcd(a, b):
def gcd(a, b): ↵
↵
while a:↵
↵
a, b = b % a, a↵
↵
return b↵
↵
x, y = map(int, input().split())↵
↵
print(gcd(x, y))↵
↵
```↵
↵
And another code.↵
```↵
import math↵
x, y = map(int, input().split())↵
print(math.gcd(x, y))↵
```↵
![ ](/predownloaded/ef/a7/efa74dfc5aed9d7328d84db38419235300d51e9b.png)↵
↵
What's the implemention of math.gcd?↵
Thanks in advance.↵
↵