c++ - Conversion of a recursive function -
the following program recursive function computes value 2 positive integers.
int riddle (int i, int j) { if (j==0) return i; return riddle(j, i%j); }
i wondering how 1 while-loop can convert program non-recursive function without if -statement?
thank help
assuming i>j, prog find hcf of 2 no.s using recursion can done using while. try :
int i=val1,j=val2; while (j != 0) { int t; t = j; j = % j; = t; }
Comments
Post a Comment