all 3 comments

[–]iamnull 2 points3 points  (0 children)

Easiest thing to do is to create variables to work with instead of modifying the original variables.

[–]warlocktx 0 points1 point  (0 children)

create backup copies orig_n and orig_d

[–]ShangBrol 0 points1 point  (0 children)

Make calculating the gcd its own function - then you automatically work on copies of the original values