InterviewSolution
Saved Bookmarks
| 1. |
The following function is a part of some class. Assume ‘x’ and ‘y’ are positive integers, greater than 0. Answer the given questions along with dry run/working.void someFun(int x, int y) {if(x>1) { if(x%y == 0) { System.out.print(y+ ""); someFun(x/y, y); } else someFun(x, y+1); } }(i) What will be returned by someFun(24, 2)? (ii) What will be returned by someFun(84, 2)?(iii) State in one line what does the function someFun() do, apart from recursion? |
|
Answer» (i) 2 2 2 3 24, 2 (ii) 2 2 3 7 84, 2 (iii) someFunOcalculates the L.C.M (Lowest Common Multiple). |
|