Print the series upto N terms
2,15,41,80,132,197,275...
Solution using C language:
#include<stdio.h>
int main()
{
int a=2,i,n;
printf("Enter the range:\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("%d ",a);
a+=13*i;
}
return 0;
}
Output:
Enter the range:
6
2 15 41 80 132 197
2,15,41,80,132,197,275...
Solution using C language:
#include<stdio.h>
int main()
{
int a=2,i,n;
printf("Enter the range:\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("%d ",a);
a+=13*i;
}
return 0;
}
Output:
Enter the range:
6
2 15 41 80 132 197
No comments:
Post a Comment