Sahib Za Khan Sahib Za Khan - 9 months ago 40
Java Question

How can I call a recursive function in reverse order

I was asked an interview question stating that how you can print number from one to the supplied parameter number to a recursive function. Say the function name is recursiveFunc When I call it like


It should print 1,2,3 to 100 and so on.

Note it should not use any other helping initializing etc variable.

Any thoughts?.....

Answer Source
public void recursiveFunc(int n) {
    if (n <= 0) 

Print after recursion.