Untitled
unknown
plain_text
2 years ago
225 B
5
Indexable
#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;
}
Editor is loading...
Leave a Comment