Write a Java program to display the first 10 numbers of the Fibonacci

How to write a Java program to display the first 10 numbers of the Fibonacci series.

Fibonacci number with Java Program

public class Fibonacci
{
public static void main(String[] args)

{
int num1=0, num2=1;
int i;
int fibo;
System.out.println(“PRINTING FIRST 10 FIBONACCI NUMBERS”);
System.out.print(” “+num1);

System.out.print(” “+num2);
for(i=3;i<=10;i++)
{
fibo=num1 + num2;
num1=num2;
num2=fibo;

System.out.print(” “+fibo);
}
}
}

Write a Java program to display the first 10 numbers of the Fibonacci
Scroll to top