Java Program to find fibonacci series of a number using recursion

Program

import java.util.Scanner;
public class FibonacciRecursion {
    int generateFibonacci(int range) {
        if (range == 0)
            return 0;
        if (range == 1)
            return 1;
        return generateFibonacci(range - 1) + generateFibonacci(range - 2);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the number to generate fibonacci series");
        int range = sc.nextInt();
        int count = 0;
        System.out.println("Fibonacci Series:");
        FibonacciRecursion fib = new FibonacciRecursion();
        for (int i = 1; i & lt; = range; i++) {
            System.out.print(fib.generateFibonacci(count) + "\t");
            count++;
        }
        System.out.println();
    }
}

Output

Enter the number to generate fibonacci series
8
Fibonacci Series:
0	1	1	2	3	5	8	13