Sahib Za Khan Sahib Za Khan - 1 year ago 74
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download