Nov-14-2017, 08:12 PM
I'm working on a project for class and I was not sure why this didn't work:
Input:
0
9
0 (Answer should be 9)
I then started adding random things to my code and discovered that the following code worked:
Input:
0
9
9
I know this is an odd question but I would like a better understanding of how that changed the code, making it work.
Input:
0
9
def hcf(a, b): for i in range(a): if a > b: a -= b elif b > a: b -= a print(a) hcf(int(input()), int(input()))Output:
0 (Answer should be 9)
I then started adding random things to my code and discovered that the following code worked:
Input:
0
9
def hcf(a, b): for i in range(a): if a > b: a -= b elif b > a: b -= a print(a or b) hcf(int(input()), int(input()))Output:
9
I know this is an odd question but I would like a better understanding of how that changed the code, making it work.