# Java Program to Display Fibonacci Series

You are Here:

## What is Fibonacci Series?

A series of numbers in which each number (Fibonacci number) is the sum of the two preceding numbers, starting from 0 and 1, i.e., 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on.

Tips: It is recommended to use our online Fibonacci Series calculator for better understanding.

## Fibonacci Series between the Given Limit

In the following example, we will find the Fibonacci Series between 0 and 100.

### Example

Java Compiler
public class myClass { public static void main(String[] args) { int limit = 100; int a = 0; int b = 1; int c = a + b; System.out.format("Fibonacci series upto %d: \n", limit); System.out.format("%d %d ", a, b); while(c <= limit) { System.out.print(c +" "); a = b; b = c; c = a + b; } } }

### Output

Fibonacci series upto 100: 0 1 1 2 3 5 8 13 21 34 55 89

## Fibonacci Series between any given Limit

In the following example, we will display the fibonacci series from 0 to any given limit.

### Example

Java Compiler
import java.util.Scanner; public class myClass { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int a = 0; int b = 1; int c = a + b; System.out.print("Enter a (int) limit: "); int limit = reader.nextInt(); System.out.format("\nFibonacci series upto %d: \n", limit); System.out.format("%d %d ", a, b); while(c <= limit) { System.out.print(c +" "); a = b; b = c; c = a + b; } } }

### Output

Enter a (int) limit: 50 Fibonacci series upto 50: 0 1 1 2 3 5 8 13 21 34

## Reminder

Hi Developers, we almost covered 90% of String functions and Interview Question on Java with examples for quick and easy learning.

We are working to cover every Single Concept in Java.