Week 8

 

 

Quiz

 

Recursion

{

System.out.println("1+2+...+100=%d\n",Sum(1,100));

}

 ...

int Sum(int a,int b)

{

if(a==b)

    return a;

else

    return Sum(a,(a+b)/2)  + Sum(1+(a+b)/2,b);

}