Java program to print N Fibonacci numbers using recursion

The first two numbers in the sequence are 0 and 1. The subsequent number are obtained by adding the previous two number. Thus, 3rd number is 0 + 1 = 14th number is 1 + 1 = 25th number is 2 + 1 = 3

To programmatically print the Nth Fibonacci number you can either use nested loop or use recursion. Here is a program that prints the first N Fibonacci numbers using recursive method. The user inputs the number of Fibonacci numbers to be printed. You then use a for loop to loop until that limit each iteration will call the function fibonacci(int num) which returns the Fibonacci number at position num. The Fibonacci function recursively calls itself adding the previous two Fibonacci numbers.