# How to do Fibonacci Sequence in Java Tutorial using NetBeans IDE

This tutorial is all about How to do Fibonacci Sequence in Java Tutorial using NetBeans IDE. In this tutorial you will learn How to use Fibonacci Sequence in Java Tutorial. Fibonacci is a set of numbers that starts with a one or a zero, followed by a one, and proceeds based on the rule that each number (called a Fibonacci number) is equal to the sum of the preceding two numbers. If the Fibonacci sequence is denoted F(n), where n is the first term in the sequence, the following equation obtains for n = 0, where the first two terms are defined as 0 and 1 by convention. This tutorial uses some package called Scanner, follow all the steps below to complete this tutorial.

How to do Fibonacci Sequence in Java Tutorial using NetBeans IDE steps

The first step is to, create your project by clicking file at the top of your project and then click new project, you can name your project whatever you want. After that you need to create you class by right clicking the Source Packages and then click the New – Java Class

After that you need to import these packages

import java.util.Scanner;

copy paste the code below:

[java]

int k, a = 1, b =1;

Scanner scanner = new Scanner(System.in);

k =0;

System.out.println(“Enter a number: “);

int number = scanner. nextInt ();

System.out.print(“1 1 “);

while(k<=number) {

k = a+ b;

if(k>=number)

break;

System.out.print(k + ” “);

a = b;

b = k;

} JOptionPane.showMessageDialog(null, e);

}

[ /java]

Then you’re done. Run your project and see if it works.

## About How To Do Fibonacci Sequence In Java

For questions or any other concerns or thesis/capstone creation with documentation, you can contact me through the following:

E-Mail: [email protected]