Pell Series is a series starting with 0 and 1 and then each next term is the sum of twice the previous term and the term before that.
Base Concept:
- T0 = 0
- T1 = 1
- Tn = (2*T(n-1))+T(n-2)
The first ten terms of Pell Series are: 0 1 2 5 12 29 70 169 408 985
If we observe the 5th term of the series that is 12 = (2*5)+2. Where 5 is the previous term of the 5th term and 2 is the term before that.
Java
import java.util.*;
public class PellSeries
{
public static void main(String args[])
{
int n=0,a=0,b=1,c=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter number of terms: ");
n=sc.nextInt();
System.out.println("Pell Series:-");
for(int i=1;i<=n;i++)
{
System.out.println(a);
c=(2*b)+a;
a=b;
b=c;
}
}
}Java