Given a number N. The task is to find first N Iccanobif Numbers.
Iccanobif Numbers are similar to Fibonacci Numbers. The K-th Iccanobif number can be obtained by addition of previous two numbers after reversing their digits.
The first few Iccanobif Numbers are:
0, 1, 1, 2, 3, 5, 8, 13, 39, 124, 514, 836, …..
Input : N = 5 Output : 0 1 1 2 3 Input : N = 9 Output : 0 1 1 2 3 5 8 13 39 Explanation: Upto 8th term, adding previous two terms is required, as there is an only single digit. For 9th term, adding 31(reversing 8th term) and 8 will give 39.
Approach: The idea is to take the first two Iccanobif Numbers as first = 0 and second = 1. Now iterate using a demoPointer N-2 times and every time find reverse of the previous two numbers using the approach discussed in: Reversing digits of a number. Find the sum of the two reversed numbers and update the variables first and second accordingly.
Below is the implementation of above approach:
0 1 1 2 3 5 8 13 39 124 514 836
Note: For larger value of N, use numbers as string.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to find GCD or HCF of two numbers
- Program to find LCM of 2 numbers without using GCD
- Program to find LCM of two numbers
- Program to find LCM of two Fibonnaci Numbers
- Program to find sum of first n natural numbers
- Program to find the LCM of two prime numbers
- Program to find sum of prime numbers between 1 to n
- Program to find first N Fermat Numbers
- Program to find if two numbers and their AM and HM are present in an array using STL
- Program to find GCD of floating point numbers
- C/C++ Program to find Prime Numbers between given range
- Program to find the percentage of difference between two numbers
- Program to find the common ratio of three numbers
- Program to find GCD or HCF of two numbers using Middle School Procedure
- Program to find HCF (Highest Common Factor) of 2 Numbers
- Program to find the maximum difference between the index of any two different numbers
- Program to find count of numbers having odd number of divisors in given range
- C++ program to find all numbers less than n, which are palindromic in base 10 and base 2.
- Program for Fibonacci numbers
- Program for harmonic mean of numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.