# Problem Statement :

Write a program to find the nth number in the Fibonacci Series.

## Input Format

The input consists of only one line with input ’N’ signifying the nth number in the Fibonacci series.

## Output Format:

The output consists of a line that contains the ‘N’th Fibonacci number.

Given:

Output:

# Explanation of given Test Cases :

## Approach:

Use recursion:

We first take ‘n’ as the input from the user. We then recursively call the function ‘fib’ with n as the parameter which in turn calls fib(n-1) and fib(n-2) until n becomes 1, at which point we return n.

# Code:

Time Complexity: Exponential
Space Complexity: O(n) if we consider the function call stack size, otherwise O(1).

# Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.

--

--

## More from Placewit

Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

## Placewit

476 Followers

Upskilling students for tech placements!