a, b = b, a + b
in python packs the values โโof b and a + b into a tuple, then unpacks it back to a and b .
C does not support this function, but uses a comma to separate between assignments, so a = b, b = a + b translates as
a = b; b = a + b;
where b gets a doubling every time because the assignment is not simultaneous.
To fix this, you will have to assign each variable separately:
b = a + b; a = b - a;
Uriel source share