Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
225 B
1
Indexable
Never
#include<stdio.h>
int main(){
int i,n,sum=0;

printf("Enter the nth term\n");
scanf("%d",&n);


for(i=1;i<=n;i+=2){
    sum+=i;
}
if(n % 2 == 1){
    sum += n*n;
  }
printf("%d",sum);





return 0;

}
Leave a Comment