
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Program to find first N Iccanobif Numbers in C++
In this tutorial, we will be discussing a program to find N lccanobif numbers.
For this we will be provided with an integer. Our task is to find the lccanobif number at that position. They are similar to the fibonacci number except the fact that we add the previous two numbers after reversing their digits.
Example
#include <bits/stdc++.h> using namespace std; //reversing the digits of a number int reverse_digits(int num){ int rev_num = 0; while (num > 0) { rev_num = rev_num * 10 + num % 10; num = num / 10; } return rev_num; } //printing the first N lccanobif numbers void icanobifNumbers(int N){ int first = 0, second = 1; if (N == 1) cout << first; else if (N == 2) cout << first << " " << second; else { cout << first << " " << second << " "; for (int i = 3; i <= N; i++) { int x = reverse_digits(first); int y = reverse_digits(second); cout << x + y << " "; int temp = second; second = x + y; first = temp; } } } int main(){ int N = 12; icanobifNumbers(N); return 0; }
Output
0 1 1 2 3 5 8 13 39 124 514 836
- Related Articles
- Program to find sum of first n natural numbers in C++
- Program to find sum of first N odd numbers in Python
- Program to find the sum of first n odd numbers in Python
- 8085 program to find the sum of first n natural numbers
- Program to generate first n lexicographic numbers in python
- PHP program to find the first ‘n’ numbers that are missing in an array
- Sum of first n natural numbers in C Program
- PHP program to find the sum of cubes of the first n natural numbers
- Java Program to cube sum of first n natural numbers
- PHP program to find the average of the first n natural numbers that are even
- PHP program to find the sum of the 5th powers of first n natural numbers
- Swift Program to calculate the sum of first N even numbers
- Swift Program to calculate the sum of first N odd numbers
- Swift Program to Calculate Cube Sum of First n Natural Numbers
- Program to find number of magic sets from a permutation of first n natural numbers in Python

Advertisements