Im trying to add odd numbers recursively from n to m but its not working . im sure its in the recursive logic on how im passing the arguments or something.

 public static int OddSum(int low, int up,int total)
     {   
         if(low==up)
         {
             return up;

         }else
         {


             low+=2;

             return total += OddSum(low,up,total+low);

         }

I Made it the solution is :

public static int OddSum(int low, int up,int total)
     {   
         int tot=total;
         tot+=low;


         if(low==up)
         {
             return tot;            
         }else
         {
             low+=2;            
             return OddSum(low,up,tot);
         }


     }

Is there any reason why you arent using a for loop?
Heres an example.

for(int i = low; i < up; i += 2)
{
    low += 2;
}

but why go to the trouble of using a recursive solution when it can be done far more easily otherwise...
Very valid question if you ask me.

probably. Which shows once again how pointless such assignments are when presented outside their context :)

This question has already been answered. Start a new discussion instead.