Iccanobif Numbers

Here given code implementation process.

//C Program
//Display Iccanobif numbers series
#include <stdio.h>

//Reverse the given number and return their result
int reverse(int number)
{
  int result = 0;
  while(number>0)
  {
  
    result=(result*10)+(number%10);
    
    number/=10;
  }
  return result;
}
//Display n iccanobif numbers
void iccanobif_number(int n)
{
 
  // Variable which are controlling execution of function
  // Set initial values to variable
  int current=0,next=1,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()
{
 
  //Size
  int n = 15;
  
  iccanobif_number(n);


  return 0;
}

Output

0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815
/*
 C++ Program
 Display Iccanobif numbers series
*/
#include<iostream>
using namespace std;

class MyNumber {
	public:

		//Reverse the given number and return their result
		int reverse(int number) {
			int result = 0;
			while (number > 0) {
				result = (result *10) + (number % 10);
				number /= 10;
			}
			return result;
		}
	//Display n iccanobif numbers
	void iccanobif_number(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) {
			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 = 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;
			}
		}
	}
};
int main() {
	MyNumber obj ;
	obj.iccanobif_number(15);
	return 0;
}

Output

 0 1 1 2 3 5 8 13 39 124 514 836 1053 4139 12815
/*
  Java Program
  Display Iccanobif numbers series
*/
public class MyNumber {
 

 
  //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/=10;
    }
    return result;
  }
  //Display n iccanobif numbers
  public void iccanobif_number(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) {

    MyNumber obj = new MyNumber();

    obj.iccanobif_number(15);
  }
}

Output

 0 1 1 2 3 5 8 13 39 124 514 836 1053 4139 12815
/*
  C# Program
  Display Iccanobif numbers series
*/
using System;
public class MyNumber {



	//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 /= 10;
		}
		return result;
	}
	//Display n iccanobif numbers
	public void iccanobif_number(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) {

			Console.Write("  " + 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) {

		MyNumber obj = new MyNumber();

		obj.iccanobif_number(15);
	}
}

Output

  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815
<?php
/*
  Php Program
  Display Iccanobif numbers series
*/
class MyNumber {
	//Reverse the given number and return their result

	public 	function reverse($number) {
		$result = 0;
		while ($number > 0) {
			$result = ($result *10) + ($number % 10);
			$number = intval($number / 10);
		}
		return $result;
	}
	//Display n iccanobif numbers

	public 	function iccanobif_number($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(" ". $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;
			}
		}
	}
};

function main() {
	$obj = new MyNumber();
	$obj->iccanobif_number(15);
}
main();

Output

 0 1 1 2 3 5 8 13 39 124 514 836 1053 4139 12815
/*
 Node Js Program
 Display Iccanobif numbers series
*/
class MyNumber {
	//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
	iccanobif_number(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) {
			process.stdout.write(" " + 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;
			}
		}
	}
}

function main(args) {
	var obj = new MyNumber();
	obj.iccanobif_number(15);
}
main();

Output

 0 1 1 2 3 5 8 13 39 124 514 836 1053 4139 12815
# Python 3 Program
# Display Iccanobif numbers series
class MyNumber :
	# 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 iccanobif_number(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
		
	

def main() :
	obj = MyNumber()
	obj.iccanobif_number(15)


if __name__ == "__main__":
	main()

Output

 0 1 1 2 3 5 8 13 39 124 514 836 1053 4139 12815
# Ruby Program 
# Display Iccanobif numbers series
class MyNumber 
	# Reverse the given number and return their result
	def reverse(number) 
		result = 0
		while (number > 0) 
			result = (result * 10) + (number % 10)
			number /= 10
		end
		return result
	end
	# Display n iccanobif numbers
	def iccanobif_number(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)
			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
def main() 
	obj = MyNumber.new()
	obj.iccanobif_number(15)
end
main()

Output

 0 1 1 2 3 5 8 13 39 124 514 836 1053 4139 12815
/*
 Scala Program
 Display Iccanobif numbers series
*/
class MyNumber {
	//Reverse the given number and return their result
	def reverse(n: Int): Int = {
		var result: Int = 0;
      	var number: Int = n;
		while (number > 0) {
			result = (result * 10) + (number % 10);
			number = (number / 10).toInt;
		}
		return result;
	}
	//Display n iccanobif numbers
	def iccanobif_number(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 = 0;
		var i: Int = 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 = 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;
		}
	}
}
object Main {
	def main(args: Array[String]): Unit = {
		var obj: MyNumber = new MyNumber();
  		obj.iccanobif_number(15);
	}
}

Output

 0 1 1 2 3 5 8 13 39 124 514 836 1053 4139 12815
/*
  Swift 4 Program
  Display Iccanobif numbers series
*/
class MyNumber {
	//Reverse the given number and return their result
	func reverse(_ n: Int) -> Int {
		var result: Int = 0;
        var number: Int = n;
		while (number > 0) {
			result = (result * 10) + (number % 10);
			number /= 10;
		}
		return result;
	}
	//Display n iccanobif numbers
	func iccanobif_number(_ 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;
		}
	}
}
func main() {
	let obj: MyNumber = MyNumber();
	obj.iccanobif_number(15);
}
main();

Output

  0  1  1  2  3  5  8  13  39  124  514  836  1053  4139  12815


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







© 2021, kalkicode.com, All rights reserved