VOOZH about

URL: https://www.geeksforgeeks.org/dsa/nth-non-fibonacci-number/

⇱ Non Fibonacci Numbers - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Non Fibonacci Numbers

Last Updated : 23 Jul, 2025

Given a positive integer n, the task is to print the nth non-Fibonacci number. The Fibonacci numbers are defined as: 

Fib(0) = 0
Fib(1) = 1
for n >1, Fib(n) = Fib(n-1) + Fib(n-2)

First few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 141, ……..

Examples:

Input : n = 2
Output : 6Input : n = 5
Output : 10
Recommended Practice

Below is the implementation of the above idea.

Output :

10


Time Complexity : O(n) , Auxiliary Space : O(1)

Now geeks you must be wondering what if we were supposed to print Non-Fibonacci Series in a range, then the code is as follows: 


Output
The Non-Fibonacci series that lies between 1 to 10 term of Fibonacci Series is: 
4 6 7 9 10 11 12 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 

Time Complexity : O(n) , Auxiliary Space : O(n)

The above problem and solution are contributed by Hemang Sarkar.

Comment
Article Tags: