#include <stdio.h>
int main()
{
int n,j=2,i,a=1,b=2,c;
int arr[20];
scanf("%d",&n);
arr[0]=a;
arr[1]=b;
for(i=1;i<=n;i++){
c=b-a;
arr[j]=c;
j++;
a=b;
b=c;
c=b+a;
arr[j]=c;
j++;
a=b;
b=c;
}
//display series
for(i=0;i<10;i++){
printf("%d,",arr[i]);
}
}
int main()
{
int n,j=2,i,a=1,b=2,c;
int arr[20];
scanf("%d",&n);
arr[0]=a;
arr[1]=b;
for(i=1;i<=n;i++){
c=b-a;
arr[j]=c;
j++;
a=b;
b=c;
c=b+a;
arr[j]=c;
j++;
a=b;
b=c;
}
//display series
for(i=0;i<10;i++){
printf("%d,",arr[i]);
}
}
No comments:
Post a Comment