Write a c program to find the nth term of the series. 1,1,2,3,4,9,8,27,16,81,32,243,....
Answers
Answered by
30
#include<stdio.h>
#include<conio.h>
void main()
{
int n,f,i;
printf("enter any number");
scanf("%d",&n);
I=f
while(i<=f)
{
n=n+I;
I++;
}
printf("nth term of series =%d",n);
getch();
}
this will guide
please mark.my answer as brainliest
#include<conio.h>
void main()
{
int n,f,i;
printf("enter any number");
scanf("%d",&n);
I=f
while(i<=f)
{
n=n+I;
I++;
}
printf("nth term of series =%d",n);
getch();
}
this will guide
please mark.my answer as brainliest
Answered by
2
- The series consists of table of 2 and table of 3 placed at the alternate positions.
- Following is the code to find the nth term of the series:
#include<stdio.h>
#include<math.h> //Math header file included
int arr[100]; //Globally declared array
int main() //Main function starts here
{ arr[0]=1; arr[1]=1;
int j=1,k=1;
int position, i;
scanf("%d",&postion);
if(position==0||position==1) //Array position starts from 0
{ printf("1"); }
for(i=2;i<=position;i++)
{ if(i%2!=0)
arr[i]=pow(3,j++); //Predefined Power function used for table of 3
else
arr[i]=pow(2,k++); //Table of 2
}
printf("%d",arr[position]);
}
Attachments:
Similar questions