fork download
  1. #include<stdio.h>
  2. int sumodd(int n)
  3. { if(n==1) { return 1; }
  4. else if(n%2==0) { return sumodd(n-1); }
  5. else return n+sumodd(n-2);
  6. }
  7.  
  8. int main()
  9. { int x;
  10. scanf("%d",&x);
  11. printf("%d",sumodd(x));
  12. return 0;
  13. }
Success #stdin #stdout 0s 5272KB
stdin
5
stdout
9