Program to find first N Iccanobif Numbers | C ++ program to find first N Icanobif numbers ; Iterative function to reverse digits of num ; Function to print first N Icanobif Numbers ; Initialize first , second numbers ; Print first two numbers ; Reversing digit of previous two terms and adding them ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int reversDigits ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } 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 = reversDigits ( first ) ; int y = reversDigits ( second ) ; cout << x + y << " ▁ " ; int temp = second ; second = x + y ; first = temp ; } } } int main ( ) { int N = 12 ; icanobifNumbers ( N ) ; return 0 ; }