Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int *s=0;
- void odd_sum(int n)
- {
- if(n%2==1)
- {
- s+=n;
- }
- else
- {
- n=n-1;
- s+=n;
- }
- if(n<0);
- {
- printf("Sum= %d\n",s);
- return;
- }
- odd_sum(n-2);
- }
- int main()
- {
- int x;
- scanf("%d",&x);
- odd_sum(x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement