fork download
  1. #include<stdio.h>
  2. int recursion(int* array,int i,int j,int size){
  3. int sum = 0;
  4. if(i < size-1){
  5. if(j < size ){
  6. printf("+(%d+%d)",array[i], array[j]);
  7. sum = sum+array[i]+array[j];
  8. j++;
  9. sum = sum + recursion(array,i,j,size);
  10. }
  11. else{
  12. i++;
  13. j=i+1;
  14. sum = sum + recursion(array,i,j,size);
  15. }
  16. }
  17. return sum;
  18. }
  19.  
  20. int main(){
  21. int i=0,j=i+1,sum=0;
  22. int a[3]={2,4,6};
  23.  
  24. int c =recursion(a,i,j,3);
  25. printf("=%d",c);
  26. return 0;
  27. }
Success #stdin #stdout 0s 2156KB
stdin
Standard input is empty
stdout
+(2+4)+(2+6)+(4+6)=24