# Java – Program to find Fibonacci series of a given number

package JavaPrograms; public class fabonacciSeries { /*Write a program to find Fibonacci series of a given no. Example : Input - 8 Output - 1 1 2 3 5 8 13 21 */ public static void main(String args[]) { int num = 6; //taking no. as command line argument. System.out.println("*****Fibonacci Series*****"); int f1=0, f2=0, f3=1, f4=0, temp=0; for(int i=1;i<=num;i++){ System.out.print(" "+f3+" "); temp =f1+f2-1; f1 = f2; f2 = f3; f3 = f1 + f2; f4 = f3 + temp; } System.out.print(" \n sum of Fabonacci series numbers "+f4+" "); } }