Untitled
unknown
plain_text
a year ago
225 B
4
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