sorry if i have posted in wrong place, i dont where else it will fit in

here is example of mod:
17 MOD 7 is 3
72 MOD 15 is 12

i have the following code:

FUNCTION Curiosity(X:Integer;Y:Integer):Integer;
IF Y = 0 THEN
Curiosity = X
ELSE
Output Y and (X MOD Y)
Curiosity = Curiosity(Y,X MOD Y)
ENDIF
END Curiosity

i have to rewrite the above as an iterative algorithm not as recursive.
i am puzzled and would greatly appreciate if someone could attempt this. however i only require it to be small, max about 20 lines, and only need it to use basic vb language, such as the following:

for and next loop, do while, if and end if, mod, etc

once again, i would really appreciate your effort to help me.