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,…

Solution :

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

Comments

Popular posts from this blog

ICSE Class 10 - Computer Application Important Program (15 Marks)

ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)

COMPUTER SCIENCE PRACTICAL SOLVED QUESTIONS - ISC BOARD 2018

Address Calculation in Single and Double Dimension Array - ISC Computer Science

ICSE CLASS 10 COMPUTER APPLICATION - Chapter 1: Concept of Objects

ISC Computer Science - Propositional Logic

COMPUTER SCIENCE PRACTICAL SOLVED QUESTIONS - ISC BOARD 2016

ICSE CLASS 10 COMPUTER APPLICATION - Chapter 2: The Java Phenomenon

Computer Science Paper 1 (Theory) - ISC 2018

Important Programme in JAVA for Class 10 ICSE Board