Question: This program is in Java. 1. The Fibonacci sequence is a well-known integer sequence that starts with the values 0 and 1 in that order).
1. The Fibonacci sequence is a well-known integer sequence that starts with the values 0 and 1 in that order). Every number after that is the sum of the two previous values in the sequence. For example, O and 1 are followed by another 1 (0 plus 1 is just 1), then by 2 (1 plus 1), 3 (1 plus 2), etc. Basically, for all n >= 2, term n is equal to (term n-1 plus term n-2) The first 10 terms of the Fibonacci sequence are 0, 1,1, 2, 3, 5, 8, 13, 21, and 34 Write a Java program that prompts the user to enter two (positive) integer values: the total length N of the Fibonacci sequence to generate (assume that this value will always be greater than or equal to 3), and a number P of terms to print (assume this value will always be less than or equal to N). Your program should print the last P terms of the first N terms of the Fibonacci sequence. For example, if the user enters 50 for N and 10 for P, your program should calculate the first 50 terms of the Fibonacci sequence, but only print the last 10 terms (basically, the 41st through 50th values) Use an ArrayList of integer values (declare its type as ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
