Hi everybody,

Today I want to share with you my solution to create a greatest common divisor function.

First , I was in wikipedia to understand how works this mathematical formula. I found this rule: gcd(a,0) = a . That’s why I chose b = 0 to stop my while loop.

Then I focused of the operations and deduce: a = b and b = a mod b . I was a trouble at the beginning when I used only two variables, the value of a was directly lost that’s why I used another one: t (for temporary)

Here is my code: github:https://github.com/aureliemartinet/TC101/blob/master/wsq12.py

Have a good day !

 

CC BY 4.0 WSQ12 #TC101 by aureliemartinette is licensed under a Creative Commons Attribution 4.0 International License.