The fibonacci sequence is a sequence of numbers in which the next number is the sum of the previous two numbers. The fir

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

The fibonacci sequence is a sequence of numbers in which the next number is the sum of the previous two numbers. The fir

Post by answerhappygod »

The fibonacci sequence is a sequence of numbers in which the
next number is the sum of the previous two numbers.
The first two numbers of the fibonacci sequence are 0, 1.
The first 8 numbers of the fibonacci sequence are 0, 1, 1, 2, 3,
5, 8, 13
Write some code to print out the first X numbers of the
fibonacci sequence.
Your output should be on one line, with each number separated by
a space. You may assume that x is at least 2.
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
System.out.print("In:");
int x = inp.nextInt();
//write your code below
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply