Iccanobif Numbers Program

Iccanobif Numbers Program in java

/*
  Java program for
  Display Iccanobif numbers series
*/
public class Numbers
{
    // Reverse the given number and 
    // return their result
    public int reverse(int number)
    {
        int result = 0;
        while (number > 0)
        {
            result = (result * 10) + (number % 10);
            number = number / 10;
        }
        return result;
    }
    // Display n iccanobif numbers
    public void isIccanobifNo(int n)
    {
        // Variable which are controlling execution 
        // of function.
        // Set initial values to variable
        int current = 0;
        int next = 1;
        int temp = 0;
        for (int i = 0; i < n; ++i)
        {
            System.out.print("  " + current);
            if (current < 10)
            {
                //When current number are contain 
                // only one digit.
                if (next > 10)
                {
                    // When next number are contain two or 
                    // more than two digit.
                    temp = next;
                    // Reverse next number and add 
                    // current result.
                    next = reverse(next) + current;
                    current = temp;
                }
                else
                {
                    // When next number are 
                    // contain only one digit.
                    next += current;
                    current = next - current;
                }
            }
            else
            {
                temp = next;
                // Reverse the digits of number
                current = reverse(current);
                next = reverse(next);
                next += current;
                current = temp;
            }
        }
    }
    public static void main(String[] args)
    {
        Numbers task = new Numbers();
        // Test
        task.isIccanobifNo(15);
    }
}
Output
  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in c++

// Include header file
#include <iostream>
//  Stdc++11 program for
//  Display Iccanobif numbers series
class Numbers
{
    // Reverse the given number and
    // return their result
    public:
    int reverse(int number)
    {
        int result = 0;
        while (number > 0)
        {
            result = (result * 10) + (number % 10);
            number = number / 10;
        }
        return result;
    }
    // Display n iccanobif numbers
    void isIccanobifNo(int n)
    {
        // Variable which are controlling execution
        // of function.
        // Set initial values to variable
        int current = 0;
        int next = 1;
        int temp = 0;
        for (int i = 0; i < n; ++i)
        {
            std::cout << "  " << current;
            if (current < 10)
            {
                // When current number are contain
                // only one digit.
                if (next > 10)
                {
                    // When next number are contain two or
                    // more than two digit.
                    temp = next;
                    // Reverse next number and add
                    // current result.
                    next = reverse(next) + current;
                    current = temp;
                }
                else
                {
                    // When next number are
                    // contain only one digit.
                    next += current;
                    current = next - current;
                }
            }
            else
            {
                temp = next;
                // Reverse the digits of number
                current = reverse(current);
                next = reverse(next);
                next += current;
                current = temp;
            }
        }
    }
};
int main(int argc, char **argv){
    Numbers task ;
    // Test
    task.isIccanobifNo(15);
	return 0;
};
Output
  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in c

// Include header file
#include <stdio.h>
#include <stdlib.h>
//  C program for
//  Display Iccanobif numbers series

// Reverse the given number and
// return their result
int reverse (int number)
{
    int result = 0;
    while(number > 0)
    {
        result = (result * 10) + (number % 10);
        number = number / 10;
    }
    return result;
}
// Display n iccanobif numbers
void  isIccanobifNo (int n)
{
    // Variable which are controlling execution
    // of function.
    // Set initial values to variable
    int current = 0;
    int next = 1;
    int temp = 0;
    for (int i = 0; i < n; i++)
    {
        printf("%d  " , current);
        if (current < 10)
        {
            // When current number are contain
            // only one digit.
            if (next > 10)
            {
                // When next number are contain two or
                // more than two digit.
                temp = next;
                // Reverse next number and add
                // current result.
                next =reverse(next) + current;
                current = temp;
            }
            else
            {
                // When next number are
                // contain only one digit.
                next += current;
                current = next - current;
            }
        }
        else
        {
            temp = next;
            // Reverse the digits of number
            current = reverse(current);
            next = reverse(next);
            next += current;
            current = temp;
        }
    }
}

int main()
{
    // Test
    isIccanobifNo(15);
	return 0; 
}
Output
0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in golang

package main
import "fmt"

//  Golang program for
//  Display Iccanobif numbers series

// Reverse the given number and
// return their result
func  reverse( number  int)int {
    var  result  int = 0;
    for(number > 0) {
        result = (result * 10) + (number % 10);
        number = number / 10;
    }
    return result;
}
// Display n iccanobif numbers
func isIccanobifNo( n  int) {
    // Variable which are controlling execution
    // of function.
    // Set initial values to variable
    var  current  int = 0;
    var  next  int = 1;
    var  temp  int = 0;
    for  i  := 0; i < n; i++ {
        fmt.Printf("%d  ",current);
        if (current < 10) {
            // When current number are contain
            // only one digit.
            if (next > 10) {
                // When next number are contain two or
                // more than two digit.
                temp = next;
                // Reverse next number and add
                // current result.
                next = reverse(next) + current;
                current = temp;
            } else {
                // When next number are
                // contain only one digit.
                next += current;
                current = next - current;
            }
        } else {
            temp = next;
            // Reverse the digits of number
            current = reverse(current);
            next = reverse(next);
            next += current;
            current = temp;
        }
    }
}

func main() {
    // Test
    isIccanobifNo(15);
}
Output
0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in c#

// Include namespace system
using System; 
//  C# program for
//  Display Iccanobif numbers series
public class Numbers
{
    // Reverse the given number and
    // return their result
    public int reverse(int number)
    {
        var result = 0;
        while (number > 0)
        {
            result = (result * 10) + (number % 10);
            number = (int)(number / 10);
        }
        return result;
    }
    // Display n iccanobif numbers
    public void isIccanobifNo(int n)
    {
        // Variable which are controlling execution
        // of function.
        // Set initial values to variable
        var current = 0;
        var ne = 1;
        var temp = 0;
        for (int i = 0; i < n; ++i)
        {
            Console.Write("  " + current.ToString());
            if (current < 10)
            {
                // When current number are contain
                // only one digit.
                if (ne > 10)
                {
                    // When next number are contain two or
                    // more than two digit.
                    temp = ne;
                    // Reverse next number and add
                    // current result.
                    ne = this.reverse(ne) + current;
                    current = temp;
                }
                else
                {
                    // When next number are
                    // contain only one digit.
                    ne += current;
                    current = ne - current;
                }
            }
            else
            {
                temp = ne;
                // Reverse the digits of number
                current = this.reverse(current);
                ne = this.reverse(ne);
                ne += current;
                current = temp;
            }
        }
    }
    public static void Main(String[] args)
    {
        var task = new Numbers();
        // Test
        task.isIccanobifNo(15);
    }
}
Output
  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in php

<?php 
//  Php program for
//  Display Iccanobif numbers series
class Numbers
{
    // Reverse the given number and
    // return their result
    function reverse($number)
    {
        $result = 0;
        while ($number > 0)
        {
            $result = ($result * 10) + ($number % 10);
            $number = (int)($number / 10);
        }
        return $result;
    }
    // Display n iccanobif numbers
    function isIccanobifNo($n)
    {
        // Variable which are controlling execution
        // of function.
        // Set initial values to variable
        $current = 0;
        $next = 1;
        $temp = 0;
        for ($i = 0; $i < $n; ++$i)
        {
            echo "  " . strval($current);
            if ($current < 10)
            {
                // When current number are contain
                // only one digit.
                if ($next > 10)
                {
                    // When next number are contain two or
                    // more than two digit.
                    $temp = $next;
                    // Reverse next number and add
                    // current result.
                    $next = $this->reverse($next) + $current;
                    $current = $temp;
                }
                else
                {
                    // When next number are
                    // contain only one digit.
                    $next += $current;
                    $current = $next - $current;
                }
            }
            else
            {
                $temp = $next;
                // Reverse the digits of number
                $current = $this->reverse($current);
                $next = $this->reverse($next);
                $next += $current;
                $current = $temp;
            }
        }
    }
}
$task = new Numbers();
// Test
$task->isIccanobifNo(15);
Output
  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in node js

//  Node Js program for
//  Display Iccanobif numbers series
class Numbers
{
    // Reverse the given number and
    // return their result
    reverse(number)
    {
        var result = 0;
        while (number > 0)
        {
            result = (result * 10) + (number % 10);
            number = parseInt(number / 10);
        }
        return result;
    }
    // Display n iccanobif numbers
    isIccanobifNo(n)
    {
        // Variable which are controlling execution
        // of function.
        // Set initial values to variable
        var current = 0;
        var next = 1;
        var temp = 0;
        for (var i = 0; i < n; ++i)
        {
            console.log("  " + current);
            if (current < 10)
            {
                // When current number are contain
                // only one digit.
                if (next > 10)
                {
                    // When next number are contain two or
                    // more than two digit.
                    temp = next;
                    // Reverse next number and add
                    // current result.
                    next = this.reverse(next) + current;
                    current = temp;
                }
                else
                {
                    // When next number are
                    // contain only one digit.
                    next += current;
                    current = next - current;
                }
            }
            else
            {
                temp = next;
                // Reverse the digits of number
                current = this.reverse(current);
                next = this.reverse(next);
                next += current;
                current = temp;
            }
        }
    }
}

var task = new Numbers();
// Test
task.isIccanobifNo(15);
Output
  0
  1
  1
  2
  3
  5
  8
  13
  39
  124
  514
  836
  1053
  4139
  12815

Iccanobif Numbers Program in typescript

//  Typescript program for
//  Display Iccanobif numbers series
class Numbers
{
    // Reverse the given number and
    // return their result
    public number reverse(number:number)
    {
        var result = 0;
        while (number > 0)
        {
            result = (result * 10) + (number % 10);
            number = parseInt(number / 10);
        }
        return result;
    }
    // Display n iccanobif numbers
    public  isIccanobifNo(n:number)
    {
        // Variable which are controlling execution
        // of function.
        // Set initial values to variable
        var current = 0;
        var next = 1;
        var temp = 0;
        for (var i = 0; i < n; ++i)
        {
            console.log("  " + current);
            if (current < 10)
            {
                // When current number are contain
                // only one digit.
                if (next > 10)
                {
                    // When next number are contain two or
                    // more than two digit.
                    temp = next;
                    // Reverse next number and add
                    // current result.
                    next = this.reverse(next) + current;
                    current = temp;
                }
                else
                {
                    // When next number are
                    // contain only one digit.
                    next += current;
                    current = next - current;
                }
            }
            else
            {
                temp = next;
                // Reverse the digits of number
                current = this.reverse(current);
                next = this.reverse(next);
                next += current;
                current = temp;
            }
        }
    }
}
var task = new Numbers();
// Test
task.isIccanobifNo(15);
/*
 file : code.ts
 tsc --target es6 code.ts
 node code.js
 */
Output
  0
  1
  1
  2
  3
  5
  8
  13
  39
  124
  514
  836
  1053
  4139
  12815

Iccanobif Numbers Program in python

#  Python 3 program for
#  Display Iccanobif numbers series
class Numbers :
    # Reverse the given number and
    # return their result
    def  reverse(self, number) :
        result = 0
        while (number > 0) :
            result = (result * 10) + (number % 10)
            number = int(number / 10)
        return result
    # Display n iccanobif numbers
    def isIccanobifNo(self, n) :
        # Variable which are controlling execution
        # of function.
        # Set initial values to variable
        current = 0
        next = 1
        temp = 0
        i = 0
        while (i < n) :
            print(current , end ="  ")
            if (current < 10) :
                # When current number are contain
                # only one digit.
                if (next > 10) :
                    # When next number are contain two or
                    # more than two digit.
                    temp = next
                    # Reverse next number and add
                    # current result.
                    next = self.reverse(next) + current
                    current = temp
                else :
                    # When next number are
                    # contain only one digit.
                    next += current
                    current = next - current
            else :
                temp = next
                # Reverse the digits of number
                current = self.reverse(current)
                next = self.reverse(next)
                next += current
                current = temp
            i += 1


if __name__=="__main__":
    task = Numbers()
    # Test
    task.isIccanobifNo(15)
Output
0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in ruby

#  Ruby program for
#  Display Iccanobif numbers series
class Numbers
    # Reverse the given number and
    # return their result
    def reverse( number)
        result = 0
        while (number > 0)
            result = (result * 10) + (number % 10)
            number = number / 10
        end
        return result
    end
    # Display n iccanobif numbers
    def isIccanobifNo( n)
        # Variable which are controlling execution
        # of function.
        # Set initial values to variable
        current = 0
        next_ = 1
        temp = 0
        i = 0
        while (i < n)
            print("  " + current.to_s)
            if (current < 10)
                # When current number are contain
                # only one digit.
                if (next_ > 10)
                    # When next number are contain two or
                    # more than two digit.
                    temp = next_
                    # Reverse next number and add
                    # current result.
                    next_ = self.reverse(next_) + current
                    current = temp
                else
                    # When next number are
                    # contain only one digit.
                    next_ += current
                    current = next_ - current
                end
            else
                temp = next_
                # Reverse the digits of number
                current = self.reverse(current)
                next_ = self.reverse(next_)
                next_ += current
                current = temp
            end
            i += 1
        end
    end
end
task = Numbers.new()
# Test
task.isIccanobifNo(15)
Output
  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in scala

//  Scala program for
//  Display Iccanobif numbers series
class Numbers ()
{
    // Reverse the given number and
    // return their result
    def reverse(num : Int) : Int=
    {
      	var number = num
        var result = 0
        while (number > 0)
        {
            result = (result * 10) + (number % 10)
            number = number / 10
        }
        return result
    }
    // Display n iccanobif numbers
    def isIccanobifNo(n : Int) : Unit=
    {
        // Variable which are controlling execution
        // of function.
        // Set initial values to variable
        var current = 0
        var next = 1
        var temp = 0
        var i = 0
        while (i < n)
        {
            print("  " + current)
            if (current < 10)
            {
                // When current number are contain
                // only one digit.
                if (next > 10)
                {
                    // When next number are contain two or
                    // more than two digit.
                    temp = next
                    // Reverse next number and add
                    // current result.
                    next = reverse(next) + current
                    current = temp
                }
                else
                {
                    // When next number are
                    // contain only one digit.
                    next += current
                    current = next - current
                }
            }
            else
            {
                temp = next
                // Reverse the digits of number
                current = reverse(current)
                next = reverse(next)
                next += current
                current = temp
            }
            i += 1
        }
    }
}

object Main 
{
	def main(args : Array[String]) : Unit=
    {
        var task = new Numbers()
        // Test
        task.isIccanobifNo(15)
    }
}
Output
  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in swift

import Foundation
//  Swift program for
//  Display Iccanobif numbers series
class Numbers
{
	// Reverse the given number and
	// return their result
	func reverse(_ num: Int) -> Int
	{
      	var number: Int = num;
		var result: Int = 0;
		while (number > 0)
		{
			result = (result * 10) + (number % 10);
			number = number / 10;
		}
		return result;
	}
	// Display n iccanobif numbers
	func isIccanobifNo(_ n: Int)
	{
		// Variable which are controlling execution
		// of function.
		// Set initial values to variable
		var current: Int = 0;
		var next: Int = 1;
		var temp: Int = 0;
		var i: Int = 0;
		while (i < n)
		{
			print(current, terminator: "  ");
			if (current < 10)
			{
				// When current number are contain
				// only one digit.
				if (next > 10)
				{
					// When next number are contain two or
					// more than two digit.
					temp = next;
					// Reverse next number and add
					// current result.
					next = self.reverse(next) + current;
					current = temp;
				}
				else
				{
					// When next number are
					// contain only one digit.
					next += current;
					current = next - current;
				}
			}
			else
			{
				temp = next;
				// Reverse the digits of number
				current = self.reverse(current);
				next = self.reverse(next);
				next += current;
				current = temp;
			}
			i += 1;
		}
	}
}
let task: Numbers = Numbers();
// Test
task.isIccanobifNo(15);
Output
0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815

Iccanobif Numbers Program in kotlin

//  Kotlin program for
//  Display Iccanobif numbers series
class Numbers {
    // Reverse the given number and
    // return their result
    fun reverse(n : Int) : Int
    {
      	var number = n;
        var result : Int = 0;
        while (number > 0)
        {
            result = (result * 10) + (number % 10);
            number = number / 10;
        }
        return result;
    }
    // Display n iccanobif numbers
    fun isIccanobifNo(n : Int) : Unit
    {
        // Variable which are controlling execution
        // of function.
        // Set initial values to variable
        var current : Int = 0;
        var next : Int = 1;
        var temp : Int;
        var i : Int = 0;
        while (i < n)
        {
            print("  " + current.toString());
            if (current < 10)
            {
                // When current number are contain
                // only one digit.
                if (next > 10)
                {
                    // When next number are contain two or
                    // more than two digit.
                    temp = next;
                    // Reverse next number and add
                    // current result.
                    next = this.reverse(next) + current;
                    current = temp;
                }
                else
                {
                    // When next number are
                    // contain only one digit.
                    next += current;
                    current = next - current;
                }
            }
            else
            {
                temp = next;
                // Reverse the digits of number
                current = this.reverse(current);
                next = this.reverse(next);
                next += current;
                current = temp;
            }
            i += 1;
        }
    }
}
fun main(args : Array<String>) : Unit
{
  val task : Numbers = Numbers();
  // Test
  task.isIccanobifNo(15);
}
Output
  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815



Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2022, kalkicode.com, All rights reserved