Question: The first five pell numbers are 0,1,2,5,12,29... Write a java program which get the whole number N and find the first pell value which is
The first five pell numbers are 0,1,2,5,12,29...
Write a java program which get the whole number N and find the first pell value which is equal or larger than N. The program should then write out the value of that pell number and also the number of that pell value. For example if the number N = 20 is written on the command line the program will return out Pell value number 5 which is 29. You can assume that N is larger than 1.
I figured out the code to find pell values for like first 20:
public class Prufa { public static void main(String[] args) { int i, P0 = 0, P1 = 1, P2; for(i = 1; i <= 20; i++) { P2 = P1 + 2*P0; P1 = P0; P0 = P2; } } }
But I'm not sure how to finish the program...
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
