## Iccanobif Numbers in Java
Thus,
Up to this point, the Iccanobif numbers are exactly the same as Fibonacci numbers. From this point onwards, we will see different numbers as compared to Fibonacci numbers. I(8) = rev(I(7)) + I(6) = rev(13) + 8 = 31 + 8 = 39. I(9) = rev(I(8)) + rev(I(7)) = rev(39) + rev(13) = 93 + 31 = 124 The rev() method reverses the digits of the numbers. We did not do the reversal of the digits of the number till I(7). It is because up to I(7), all numbers are single digits numbers, and when we reverse a single-digit number, we get the same number. For example rev(3) = 3. Since reversing the digit has no impact on the numbers till I(7), the numbers are the same as the Fibonacci numbers. Thus, the Iccanobif numbers series is: 0, 1, 1, 2, 3, 5, 8, 13, From 39, the Iccanobif numbers differ from the Fibonacci numbers. That's why we have highlighted the number 39. Let's see the different approaches to implement the Iccanobif Numbers. ## Recursive ApproachLet's see how one can use recursion to find the Iccanobif numbers.
The first 10 Iccanobif Numbers are: 0 1 1 2 3 5 8 13 39 124
The above program is consuming a lot of time to find the Iccanobif numbers. Thus, we need to optimize it further to reduce the time complexity. The following approach does the same. ## Iterative ApproachThe above program is consuming a lot of time to find the Iccanobif numbers. Therefore, we need to optimize it further to reduce the time complexity.
The first 10 Iccanobif Numbers are: 0 1 1 2 3 5 8 13 39 124
In terms of space complexity, we can even do some more optimization. If we look carefully, we find that we only need two variables: one for storing the second last Iccanobif number and the other for storing the last Iccanobif number. Thus, we have avoided the usage of an array. See the following program.
The first 10 Iccanobif Numbers are: 0 1 1 2 3 5 8 13 39 124
## Note: While doing the complexity analysis, we have assumed that the reversing digits of a number take O(1), i.e., constant time. For reversing the digits, one may take the help of the reverse() method of the StringBuilder class. However, before doing that, it is required to convert the numbers into Strings. |

For Videos Join Our Youtube Channel: Join Now

- Send your Feedback to [email protected]