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.
- 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 sum of prime numbers between 1 to n
- Program to find LCM of two Fibonnaci Numbers
- Program to find first N Fermat Numbers
- Program to find sum of first n natural numbers
- Program to find GCD of floating point numbers
- 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.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.