Find Nth Kynea Number

Here given code implementation process.

//C Program
//Find Nth Kynea Number
#include <stdio.h>


int pow_number(int number,int size)
{
  if(number==0)
  {
    return 0;
  }
  else if(size==0)
  {
    return 1;
  }
  else
  {
    int result=number;

    for (int i = 2; i <= size; ++i)
    {
      result=result*number;
    }
    return result;
  }
}
void kynea_number(int number)
{

  if(number <= 0)
  {
    //when invalid kynea number
    return;
  }


  printf("%d 'nth Kynea number is : %d\n",number,(pow_number(2,2*number) + pow_number(2,number+1) -1 ));

}
int main()
{
  kynea_number(4);
  kynea_number(7);
  kynea_number(9);
  kynea_number(15);
  return 0;
}

Output

4 'nth Kynea number is : 287
7 'nth Kynea number is : 16639
9 'nth Kynea number is : 263167
15 'nth Kynea number is : 1073807359
/*
  C++ Program
  Find Nth Kynea Number
*/
#include<iostream>

using namespace std;


class MyNumber {
	public:
		int pow_number(int number, int size) {
			if (number == 0) {
				return 0;
			} else
			if (size == 0) {
				return 1;
			} else {
				int result = number;
				for (int i = 2; i <= size; ++i) {
					result = result *number;
				}
				return result;
			}
		}
	void kynea_number(int number) {
		if (number <= 0) {
			return;
		}
		cout << number << " 'nth Kynea number is : " << pow_number(2,2*number) + pow_number(2,number+1) -1  << "\n";
	}
};
int main() {
	MyNumber obj;
	obj.kynea_number(4);
	obj.kynea_number(7);
	obj.kynea_number(9);
	obj.kynea_number(15);
	return 0;
}

Output

4 'nth Kynea number is : 287
7 'nth Kynea number is : 16639
9 'nth Kynea number is : 263167
15 'nth Kynea number is : 1073807359
/*
  Java Program
  Find Nth Kynea Number
*/
public class MyNumber {


  public int pow_number(int number,int size)
  {
    if(number==0)
    {
      return 0;
    }
    else if(size==0)
    {
      return 1;
    }
    else
    {
      int result=number;

      for (int i = 2; i <= size; ++i)
      {
        result=result*number;
      }
      return result;
    }
  }
  public void kynea_number(int number)
  {

    if(number <= 0)
    {
      //when invalid kynea number
      return;
    }


    System.out.print(number+" 'nth Kynea number is : "+(pow_number(2,2*number) + pow_number(2,number+1) -1 )+"\n");

  }
  public static void main(String[] args) {
  

    MyNumber obj = new MyNumber();
   
    obj.kynea_number(4);
    obj.kynea_number(7);
    obj.kynea_number(9);
    obj.kynea_number(15);
  }
}

Output

4 'nth Kynea number is : 287
7 'nth Kynea number is : 16639
9 'nth Kynea number is : 263167
15 'nth Kynea number is : 1073807359
#   Python 3 Program
#   Find Nth Kynea Number
class MyNumber :
	def pow_number(self, number, size) :
		if (number == 0) :
			return 0
		elif (size == 0) :
			return 1
		else :
			result = number
			i = 2
			while (i <= size) :
				result = result * number
				i += 1
			
			return result
		
	
	def kynea_number(self, number) :
		if (number <= 0) :
			return
		
		print(number ," 'nth Kynea number is : ", (self.pow_number(2, 2 * number) + self.pow_number(2, number + 1) - 1) ,"\n", end = "")
	

def main() :
	obj = MyNumber()
	obj.kynea_number(4)
	obj.kynea_number(7)
	obj.kynea_number(9)
	obj.kynea_number(15)


if __name__ == "__main__":
	main()

Output

4  'nth Kynea number is :  287
7  'nth Kynea number is :  16639
9  'nth Kynea number is :  263167
15  'nth Kynea number is :  1073807359
#   Ruby Program
#   Find Nth Kynea Number
class MyNumber 
	def pow_number(number, size) 
		if (number == 0) 
			return 0
		elsif (size == 0) 
			return 1
		else 
			result = number
			i = 2
			while (i <= size) 
				result = result * number
				i += 1
			end
			return result
		end
	end
	def kynea_number(number) 
		if (number <= 0) 
			return
		end
		print(number ," 'nth Kynea number is  :", (self.pow_number(2, 2 * number) + self.pow_number(2, number + 1) - 1) ,"\n")
	end
end
def main() 
	obj = MyNumber.new()
	obj.kynea_number(4)
	obj.kynea_number(7)
	obj.kynea_number(9)
	obj.kynea_number(15)
end
main()

Output

4 'nth Kynea number is  :287
7 'nth Kynea number is  :16639
9 'nth Kynea number is  :263167
15 'nth Kynea number is  :1073807359
/*
  Scala Program
  Find Nth Kynea Number
*/
class MyNumber {
	def pow_number(number: Int, size: Int): Int = {
		if (number == 0) {
			return 0;
		} else
		if (size == 0) {
			return 1;
		} else {
			var result: Int = number;
			var i: Int = 2;
			while (i <= size) {
				result = result * number;
				i += 1;
			}
			return result;
		}
	}
	def kynea_number(number: Int): Unit = {
		if (number <= 0) {
			return;
		}
		print(""+number + " 'nth Kynea number is : " + (this.pow_number(2, 2 * number) + this.pow_number(2, number + 1) - 1) + "\n");
	}
}
object Main {
	def main(args: Array[String]): Unit = {
		val obj: MyNumber = new MyNumber();
		obj.kynea_number(4);
		obj.kynea_number(7);
		obj.kynea_number(9);
		obj.kynea_number(15);
	}
}

Output

4 'nth Kynea number is : 287
7 'nth Kynea number is : 16639
9 'nth Kynea number is : 263167
15 'nth Kynea number is : 1073807359
/*
  Swift Program
  Find Nth Kynea Number
*/
class MyNumber {
	func pow_number(_ number: Int, _ size: Int) -> Int {
		if (number == 0) {
			return 0;
		} else
		if (size == 0) {
			return 1;
		} else {
			var result: Int = number;
			var i: Int = 2;
			while (i <= size) {
				result = result * number;
				i += 1;
			}
			return result;
		}
	}
	func kynea_number(_ number: Int) {
		if (number <= 0) {
			return;
		}
		print(number ," 'nth Kynea number is : ", (pow_number(2, 2 * number) + pow_number(2, number + 1) - 1) ,"\n", terminator: "");
	}
}
func main() {
	let obj: MyNumber = MyNumber();
	obj.kynea_number(4);
	obj.kynea_number(7);
	obj.kynea_number(9);
	obj.kynea_number(15);
}
main();

Output

4  'nth Kynea number is :  287
7  'nth Kynea number is :  16639
9  'nth Kynea number is :  263167
15  'nth Kynea number is :  1073807359
<?php
/*
  Php Program
  Find Nth Kynea Number
*/
class MyNumber {
	public 	function pow_number($number, $size) {
		if ($number == 0) {
			return 0;
		} else
		if ($size == 0) {
			return 1;
		} else {
			$result = $number;
			for ($i = 2; $i <= $size; ++$i) {
				$result = $result *$number;
			}
			return $result;
		}
	}
	public 	function kynea_number($number) {
		if ($number <= 0) {
			return;
		}
		echo($number ." 'nth Kynea number is : ". ($this->pow_number(2, 2 *$number) + $this->pow_number(2, $number + 1) - 1) ."\n");
	}
};

function main() {
	$obj = new MyNumber();
	$obj->kynea_number(4);
	$obj->kynea_number(7);
	$obj->kynea_number(9);
	$obj->kynea_number(15);

}
main();

Output

4 'nth Kynea number is : 287
7 'nth Kynea number is : 16639
9 'nth Kynea number is : 263167
15 'nth Kynea number is : 1073807359
/*
  Node Js Program
  Find Nth Kynea Number
*/
class MyNumber {
	pow_number(number, size) {
		if (number == 0) {
			return 0;
		} else
		if (size == 0) {
			return 1;
		} else {
			var result = number;
			for (var i = 2; i <= size; ++i) {
				result = result *number;
			}

			return result;
		}
	}
	kynea_number(number) {
		if (number <= 0) {
			return;
		}

		process.stdout.write(number + " 'nth Kynea number is : " + (this.pow_number(2, 2 *number) + this.pow_number(2, number + 1) - 1) + "\n");
	}
}

function main(args) {
	var obj = new MyNumber();
	obj.kynea_number(4);
	obj.kynea_number(7);
	obj.kynea_number(9);
	obj.kynea_number(15);
}

main();

Output

4 'nth Kynea number is : 287
7 'nth Kynea number is : 16639
9 'nth Kynea number is : 263167
15 'nth Kynea number is : 1073807359
using System;

/*
  C# Program
  Find Nth Kynea Number
*/

public class MyNumber {
	public int pow_number(int number, int size) {
		if (number == 0) {
			return 0;
		} else
		if (size == 0) {
			return 1;
		} else {
			int result = number;
			int i = 2;
			while (i <= size) {
				result = result * number;
				i++;
			}
			return result;
		}
	}
	public void kynea_number(int number) {
		if (number <= 0) {
			return;
		}
		Console.Write(number + " 'nth Kynea number is : " + (pow_number(2, 2 * number) + pow_number(2, number + 1) - 1) + "\n");
	}
	public static void Main(String[] args) {
		MyNumber obj = new MyNumber();
		obj.kynea_number(4);
		obj.kynea_number(7);
		obj.kynea_number(9);
		obj.kynea_number(15);
	}
}

Output

4 'nth Kynea number is : 287
7 'nth Kynea number is : 16639
9 'nth Kynea number is : 263167
15 'nth Kynea number is : 1073807359


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