write a program to print the first 15 numbers of the Pell series.Pell series is a series which starts from 1 and 2 and subsequent number are the sum of twice the previous number and the number previous to the previous number.Pell series:1 ,2,5,12,12,29,70,169,408,985,2378,5471,13860
Answers
program to print the first 15 numbers of the Pell series.Pell series is a series which starts from 1 and 2 and subsequent number are the sum of twice the previous number and the number previous to the previous number.Pell series:1 ,2,5,12,12,29,70,169,408,985,2378,5471,13860....
.....
Question:
Write a program to print the first 15 numbers of the Pell series. Pell series is such a series which starts from 1 and 2 , and subsequent numbers are the sum of twice the previous number and the number previous to the previous number. Pell series: 1, 2, 5, 12, 29, 70, 169, 408, 985, 2378, 5741, 13860, …
Solution:
Language used: Java
public class PellSeries
{
static void main()
{
int i,a=1,b=0,c;
System.out.println("Pell series =");
for(i=1;i<=15;i++)
{
c=a+2*b;
System.out.print(c+" ");
a=b;
b=c;
}
}
}