Nth Fibonacci Number Problem Statement

Calculate the Nth term in the Fibonacci sequence, where the sequence is defined as follows: F(n) = F(n-1) + F(n-2), with initial conditions F(1) = F(2) = 1.

Input:

The input consists of a single integer ‘N’ for each test case.

Output:

Return the Nth Fibonacci number for each test case.

Example:

Input:
N = 5
Output:
5
Explanation:

The Fibonacci sequence up to the 5th term is: 1, 1, 2, 3, 5. Hence, the 5th Fibonacci number is 5.

Constraints:

  • 1 <= N <= 10000
  • Input ‘N’ is a positive integer.
Note

You are required to implement the function and return the result. The focus is on calculating efficiently within the given time limit.

AnswerBot
4mo

Calculate the Nth Fibonacci number efficiently using dynamic programming.

  • Use dynamic programming to store previously calculated Fibonacci numbers to avoid redundant calculations.

  • Start with base cases ...read more

Badhepudi Madhavi
3mo
5
Anonymous
4mo
Priya
Select
Add answer anonymously...

HCLTech Software Engineer interview questions & answers

A Software Engineer was asked 1mo agoQ. Can you explain the difference between a stack and a queue?
A Software Engineer was asked 2mo agoQ. Write code to check if a string is a palindrome.
A Software Engineer was asked 2mo agoQ. How do you copy files from blob storage from a source container to a target cont...read more

Popular interview questions of Software Engineer

A Software Engineer was asked 1mo agoQ1. Can you explain the difference between a stack and a queue?
A Software Engineer was asked 2mo agoQ2. Write code to check if a string is a palindrome.
A Software Engineer was asked 2mo agoQ3. How do you copy files from blob storage from a source container to a target cont...read more

Top HR questions asked in HCLTech Software Engineer

A Software Engineer was asked 1mo agoQ1. Tell me about the challenging technical problem you faced and how it was solved?
A Software Engineer was asked 1mo agoQ2. What interests you about working at our company?
A Software Engineer was asked 1mo agoQ3. What skills do you possess?
HCLTech Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits