Q:

Write a program in C to print the first 20 numbers of the Pell series

0

Write a program in C to print the first 20 numbers of the Pell series

Expected Output :
The first 20 numbers of Pell series are:
0 1 2 5 12 29 70 169 408 985 2378 5741 13860 33461 80782 195025 470832 1136689 2744210 6625109

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

# include <stdio.h>
# include <stdlib.h>


int main()
{
	int n,a=1,b=0,c;
	printf("\n\n Find the first 20 numbers of the Pell series: \n");
	printf(" --------------------------------------------------\n");	
    printf(" The first 20 numbers of Pell series are: \n");
    c=0;
    printf(" %d ",c);
    for(n=1; n<20; n++)
     {
      c= a + 2*b;
      printf("%d ",c);
      a = b;
      b = c;
     }
	 printf("\n");
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now