Write a program to print the first 15 numbers of the Pell series in JAVA Prgramming Language
Write a program to print the first 15 numbers of the Pell series in JAVA Prgramming Language
In mathematics, the Pell numbers are an infinite sequence of integers. The sequence of Pell numbers starts with 0 and 1, and then each Pell number is the sum of twice the previous Pell number and the Pell number before that.:
thus, 70 is the companion to 29, and 70 = 2 × 29 + 12 = 58 + 12.
The first few terms of the sequence are :
0, 1, 2, 5, 12, 29, 70, 169, 408, 985, 2378, 5741, 13860,…
thus, 70 is the companion to 29, and 70 = 2 × 29 + 12 = 58 + 12.
The first few terms of the sequence are :
0, 1, 2, 5, 12, 29, 70, 169, 408, 985, 2378, 5741, 13860,…
import java.util.*;
public class pellnumber
{
public static void main(String args[])
{
int n,a=1,b=0,c;
System.out.println("First 20 Pell numbers: ");
for(n=1; n<=20; n++)
{
c= a + 2*b;
System.out.print(c+" ");
a = b;
b = c;
}
}
}
Back to Programme List
Loved reading this blog—such a clear breakdown of how tuition for Computer Science helps students move beyond theory and actually build problem-solving skills. The focus on logic, coding confidence, and real-world application really stands out. Platforms like Ziyyara are doing a great job making quality CS learning accessible with expert-led, student-friendly online support.
ReplyDeleteContact us at 9654271931.
Visit: Computer Science online tuition