Page Contents

## Interview Content

- C Programming Coding Questions
- C Pattern Programming Questions
- C Programming Interview Questions
- Java Programming Coding Questions
- Java Pattern Programming Questions
- Java Programming Interview Questions
- Python Programming Coding Questions
- Python Pattern Programming Questions
- Python Programming Interview Questions
- SQL Interview Questions

# Fibonacci series program in Java using Recursion

**Ans: **

In this tutorial we are going to learn how to print Fibonacci series in java program using recursion.

**Read this:** *What is Fibonacci Series? Fibonacci series program in C using recursion.*

## How this Java program will behave?

Its Logic is different from Fibonacci series program in C using iteration.

Here we have a function named fibonacci() which is recursive. Each time it will call itself to calculate the elements of the series.

This Fibonacci series program will take integer as input. And print series upto given input.

Suppose if someone has given 6 as input, output will be

0, 1, 1, 2, 3, 5

## Java program to print Fibonacci series using recursive function

```
import java.util.*;
class Main{
public static void main(String ...a){
int i, k;
Scanner sc= new Scanner(System.in);
System.out.print("Enter number- ");
int n= sc.nextInt();
System.out.println("fibonacci series is: ");
for(i=0;i<n;i++) {
System.out.println(Main.fibonacci(i));
}
}
static int fibonacci(int i){
if(i==0) return 0;
else if(i==1) return 1;
else return (fibonacci(i-1)+fibonacci(i-2));
}
}
```

**Output:**

## Also prepare these Java Programs:

- Write a program in Java to print the Fibonacci series using iterative method.
- Palindrome program in Java using Iterative method
- Java program to find largest of three numbers
- Java program to sum the digits of a number using recursion
- Java program to swap two numbers using third variable
- Java Program to check if two strings are anagrams
- Java program to find largest and smallest number in an array
- Java Program to find top two maximum number in array
- Java Program to remove duplicate elements from an array

##### Latest Uploads on Website

- AVL Tree with explanation
- Radix sort algorithm explanation with example
- Quick Sort Algorithm with explanation
- Bubble sorting algorithm with Bubble sort program in C
- Insertion sort algorithm and program in C
- Selection Sort Algorithm and Program in C
- Linear probing technique explanation with example
- Collision in Hashing and Collision resolution technique
- Hashing in data structure with its types
- Binary search tree operations with Program
- Binary search tree in data structure
- Binary search algorithm in data structure with explanation
- linear search in data structure with Algo and Program