forum

Home / DeveloperSection / Forums / Understanding recursive method. Help!

Understanding recursive method. Help!

Royce Roy 1438 29-Apr-2015
This code is  working(it's purpose is to return the product of n odd numbers). My problem is, I do not understand how exactly works. What goes after what, how exactly the values are caluclated and multiplied and what happens in the return after n==1. 
Sorry if I am asking for too much, but can someone explain this to me in detail? 
public static int multiplyOdds (int n) {
        System.out.println(n);
        if(n==1){
        return 1;
         
        }else return  multiplyOdds(n-1) * (n*2-1);
         
         
    }

Updated on 29-Apr-2015

Can you answer this question?


Answer

1 Answers

Liked By