Programming Examples

Java program to print the first 15 numbers of the Pell series


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 is 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

class Pell
{
	public static void main(Strign arr[])
	{
		int i,f=1,s=0,t;
		for(i=1;i<=15;i++)
		{
			t=f+s*2;
			System.out.print(t);
			f=s;
			s=t;	
		}		
	}
}
Output

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad