import java.io.*; import java.lang.*; class Fibonacci { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the value:"); int n=Integer.parseInt(br.readLine()); int t1=0,t2=1; System.out.print("Fibonacci Series is "+t1+" "+t2); for(int i=0; i<n; i++) { int t3=t1+t2; t1=t2; t2=t3; System.out.print(" "+t3); } } }
OUTPUT:
Enter the value: 10 fibnocci series is 0 1 1 2 3 5 8 13 21 34 55 89
This program prints the series given by user plus two numbers 0 and 1. If you want exact number, refer this java program to print the Fibonacci Series in Java