Find the nth icosikaipentagon number

Here given code implementation process.

// C Program
// Find the nth icosikaipentagon number
#include <stdio.h>

void nthIcosikaipentagonNo(int n)
{
  	// Formula = (23n²-21n)/2
	int result = (23 * n * n - 21 * n) / 2;
	printf("\n Given n : %d", n);
	// Display calculated value
	printf("\n Result  :  %d", result);
}
int main()
{
	// Test A
	// n = 5
	nthIcosikaipentagonNo(5);
	// Test B
	// n = 7
	nthIcosikaipentagonNo(7);
	return 0;
}

Output

 Given n : 5
 Result  :  235
 Given n : 7
 Result  :  490
// Java Program 
// Find the nth icosikaipentagon number
public class IcosikaipentagonNo
{
	public void nthIcosikaipentagonNo(int n)
	{
		// Formula = (23n²-21n)/2
		int result = (23 * n * n - 21 * n) / 2;
		System.out.print("\n Given n : " + n);
		// Display calculated value
		System.out.print("\n Result : " + result);
	}
	public static void main(String args[])
	{
		IcosikaipentagonNo task = new IcosikaipentagonNo();
		// Test A
		// n = 5
		task.nthIcosikaipentagonNo(5);
		// Test B
		// n = 7
		task.nthIcosikaipentagonNo(7);
	}
}

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490
// Include header file
#include <iostream>
using namespace std;
// C++ Program 
// Find the nth icosikaipentagon number
class IcosikaipentagonNo
{
	public: void nthIcosikaipentagonNo(int n)
	{
		// Formula = (23n²-21n)/2
		int result = (23 *n *n - 21 *n) / 2;
		cout << "\n Given n : " << n;
		// Display calculated value
		cout << "\n Result : " << result;
	}
};
int main()
{
	IcosikaipentagonNo *task = new IcosikaipentagonNo();
	// Test A
	// n = 5
	task->nthIcosikaipentagonNo(5);
	// Test B
	// n = 7
	task->nthIcosikaipentagonNo(7);
	return 0;
}

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490
// Include namespace system
using System;
// Csharp Program 
// Find the nth icosikaipentagon number
public class IcosikaipentagonNo
{
	public void nthIcosikaipentagonNo(int n)
	{
		// Formula = (23n²-21n)/2
		int result = (23 * n * n - 21 * n) / 2;
		Console.Write("\n Given n : " + n);
		// Display calculated value
		Console.Write("\n Result : " + result);
	}
	public static void Main(String[] args)
	{
		IcosikaipentagonNo task = new IcosikaipentagonNo();
		// Test A
		// n = 5
		task.nthIcosikaipentagonNo(5);
		// Test B
		// n = 7
		task.nthIcosikaipentagonNo(7);
	}
}

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490
package main
import "fmt"
// Go Program 
// Find the nth icosikaipentagon number
type IcosikaipentagonNo struct {}
func getIcosikaipentagonNo() * IcosikaipentagonNo {
	var me *IcosikaipentagonNo = &IcosikaipentagonNo {}
	return me
}
func(this IcosikaipentagonNo) nthIcosikaipentagonNo(n int) {
	// Formula = (23n²-21n)/2
	var result int = (23 * n * n - 21 * n) / 2
	fmt.Print("\n Given n : ", n)
	// Display calculated value
	fmt.Print("\n Result : ", result)
}
func main() {
	var task * IcosikaipentagonNo = getIcosikaipentagonNo()
	// Test A
	// n = 5
	task.nthIcosikaipentagonNo(5)
	// Test B
	// n = 7
	task.nthIcosikaipentagonNo(7)
}

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490
<?php
// Php Program 
// Find the nth icosikaipentagon number
class IcosikaipentagonNo
{
	public	function nthIcosikaipentagonNo($n)
	{
		// Formula = (23n²-21n)/2
		$result = (int)((23 * $n * $n - 21 * $n) / 2);
		echo("\n Given n : ".$n);
		// Display calculated value
		echo("\n Result : ".$result);
	}
}

function main()
{
	$task = new IcosikaipentagonNo();
	// Test A
	// n = 5
	$task->nthIcosikaipentagonNo(5);
	// Test B
	// n = 7
	$task->nthIcosikaipentagonNo(7);
}
main();

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490
// Node JS Program 
// Find the nth icosikaipentagon number
class IcosikaipentagonNo
{
	nthIcosikaipentagonNo(n)
	{
		// Formula = (23n²-21n)/2
		var result = parseInt((23 * n * n - 21 * n) / 2);
		process.stdout.write("\n Given n : " + n);
		// Display calculated value
		process.stdout.write("\n Result : " + result);
	}
}

function main()
{
	var task = new IcosikaipentagonNo();
	// Test A
	// n = 5
	task.nthIcosikaipentagonNo(5);
	// Test B
	// n = 7
	task.nthIcosikaipentagonNo(7);
}
main();

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490
#  Python 3 Program 
#  Find the nth icosikaipentagon number
class IcosikaipentagonNo :
	def nthIcosikaipentagonNo(self, n) :
		#  Formula = (23n²-21n)/2
		result = int((23 * n * n - 21 * n) / 2)
		print("\n Given n : ", n, end = "")
		#  Display calculated value
		print("\n Result : ", result, end = "")
	

def main() :
	task = IcosikaipentagonNo()
	#  Test A
	#  n = 5
	task.nthIcosikaipentagonNo(5)
	#  Test B
	#  n = 7
	task.nthIcosikaipentagonNo(7)

if __name__ == "__main__": main()

Output

 Given n :  5
 Result :  235
 Given n :  7
 Result :  490
#  Ruby Program 
#  Find the nth icosikaipentagon number
class IcosikaipentagonNo 
	def nthIcosikaipentagonNo(n) 
		#  Formula = (23n²-21n)/2
		result = (23 * n * n - 21 * n) / 2
		print("\n Given n : ", n)
		#  Display calculated value
		print("\n Result : ", result)
	end

end

def main() 
	task = IcosikaipentagonNo.new()
	#  Test A
	#  n = 5
	task.nthIcosikaipentagonNo(5)
	#  Test B
	#  n = 7
	task.nthIcosikaipentagonNo(7)
end

main()

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490
// Scala Program 
// Find the nth icosikaipentagon number
class IcosikaipentagonNo()
{
	def nthIcosikaipentagonNo(n: Int): Unit = {
		// Formula = (23n²-21n)/2
		var result: Int = (23 * n * n - 21 * n) / 2;
		print("\n Given n : " + n);
		// Display calculated value
		print("\n Result : " + result);
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: IcosikaipentagonNo = new IcosikaipentagonNo();
		// Test A
		// n = 5
		task.nthIcosikaipentagonNo(5);
		// Test B
		// n = 7
		task.nthIcosikaipentagonNo(7);
	}
}

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490
// Swift 4 Program 
// Find the nth icosikaipentagon number
class IcosikaipentagonNo
{
	func nthIcosikaipentagonNo(_ n: Int)
	{
		// Formula = (23n²-21n)/2
		let result: Int = (23 * n * n - 21 * n) / 2;
		print("\n Given n : ", n, terminator: "");
		// Display calculated value
		print("\n Result : ", result, terminator: "");
	}
}
func main()
{
	let task: IcosikaipentagonNo = IcosikaipentagonNo();
	// Test A
	// n = 5
	task.nthIcosikaipentagonNo(5);
	// Test B
	// n = 7
	task.nthIcosikaipentagonNo(7);
}
main();

Output

 Given n :  5
 Result :  235
 Given n :  7
 Result :  490
// Kotlin Program 
// Find the nth icosikaipentagon number
class IcosikaipentagonNo
{
	fun nthIcosikaipentagonNo(n: Int): Unit
	{
		// Formula = (23n²-21n)/2
		val result: Int = (23 * n * n - 21 * n) / 2;
		print("\n Given n : " + n);
		// Display calculated value
		print("\n Result : " + result);
	}
}
fun main(args: Array < String > ): Unit
{
	val task: IcosikaipentagonNo = IcosikaipentagonNo();
	// Test A
	// n = 5
	task.nthIcosikaipentagonNo(5);
	// Test B
	// n = 7
	task.nthIcosikaipentagonNo(7);
}

Output

 Given n : 5
 Result : 235
 Given n : 7
 Result : 490


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