Java Program to find fibonacci series of a number

Program

import java.util.Scanner;
public class FibonacciSeries {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the range of fibonacci series");
        int range = sc.nextInt();
        if (range & lt; = 0) {
            System.out.println("Cannot generate fibonacci series");
            System.exit(0);
        }
        int first = 0;
        int second = 1;
        System.out.println("Fibonacci Series:");
        if (range == 1)
            System.out.println(first);
        else if (range & gt; = 2) {
            System.out.print(first + "\t" + second);
            for (int i = 0; i & lt; range - 2; i++) {
                int fib = first + second;
                System.out.print("\t" + fib);
                first = second;
                second = fib;
            }
            System.out.println();
        }
    }
}

Output

Enter the range of fibonacci series
8
Fibonacci Series:
0	1	1	2	3	5	8	13