Icosahedral number

Here given code implementation process.

// C Program for
// Icosahedral number
#include <stdio.h>

void icosahedralNo(int k)
{
	// Print all initial k icosahedral number
	for (int n = 1; n <= k; ++n)
	{
		// Formula
		//  n(5n²-5n+2)
		// ——————————————
		//       2
      
		// Calculate nth icosahedral number
		int result = (n *(5 *(n *n) - 5 *n + 2)) / 2;
      
		// Display calculated result
		printf("  %d", result);
	}
}
int main()
{
	//  Icosahedral number are
	// —————————————————————————————————————————————
	//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
    //  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	//  42276, 47412, 52948, 58899, 65280, 72106, 
	//  79392, 87153, 95404 ... etc
  
	// k = 10
	icosahedralNo(10);
	return 0;
}

Output

  1  12  48  124  255  456  742  1128  1629  2260
// Java program for
// Icosahedral number
public class IcosahedralNumber
{
	public void icosahedralNo(int k)
	{
		// Print all initial k icosahedral number
		for (int n = 1; n <= k; ++n)
		{
			// Formula
			//  n(5n²-5n+2)
			// ——————————————
			//       2
          
			// Calculate nth icosahedral number
			int result = (n * (5 * (n * n) - 5 * n + 2)) / 2;
          
			// Display calculated result
			System.out.print(" " + result);
		}
	}
	public static void main(String[] args)
	{
		IcosahedralNumber task = new IcosahedralNumber();
		//  Icosahedral number are
		// —————————————————————————————————————————————
		//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
		//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
		//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
		//  42276, 47412, 52948, 58899, 65280, 72106, 
		//  79392, 87153, 95404 ... etc
      
		// k = 10
		task.icosahedralNo(10);
	}
}

Output

 1 12 48 124 255 456 742 1128 1629 2260
// Include header file
#include <iostream>
using namespace std;
// C++ program for
// Icosahedral number

class IcosahedralNumber
{
	public: void icosahedralNo(int k)
	{
		// Print all initial k icosahedral number
		for (int n = 1; n <= k; ++n)
		{
			// Formula
			//  n(5n²-5n+2)
			// ——————————————
			//       2
          
			// Calculate nth icosahedral number
			int result = (n *(5 *(n *n) - 5 *n + 2)) / 2;
          
			// Display calculated result
			cout << " " << result;
		}
	}
};
int main()
{
	IcosahedralNumber *task = new IcosahedralNumber();
	//  Icosahedral number are
	// —————————————————————————————————————————————
	//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
	//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	//  42276, 47412, 52948, 58899, 65280, 72106, 
	//  79392, 87153, 95404 ... etc
  
	// k = 10
	task->icosahedralNo(10);
	return 0;
}

Output

 1 12 48 124 255 456 742 1128 1629 2260
// Include namespace system
using System;
// Csharp program for
// Icosahedral number
public class IcosahedralNumber
{
	public void icosahedralNo(int k)
	{
		// Print all initial k icosahedral number
		for (int n = 1; n <= k; ++n)
		{
			// Formula
			//  n(5n²-5n+2)
			// ——————————————
			//       2
          
			// Calculate nth icosahedral number
			int result = (n * (5 * (n * n) - 5 * n + 2)) / 2;
          
			// Display calculated result
			Console.Write(" " + result);
		}
	}
	public static void Main(String[] args)
	{
		IcosahedralNumber task = new IcosahedralNumber();
		//  Icosahedral number are
		// —————————————————————————————————————————————
		//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
		//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
		//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
		//  42276, 47412, 52948, 58899, 65280, 72106, 
		//  79392, 87153, 95404 ... etc
      
		// k = 10
		task.icosahedralNo(10);
	}
}

Output

 1 12 48 124 255 456 742 1128 1629 2260
package main
import "fmt"
// Go program for
// Icosahedral number

func icosahedralNo(k int) {
	// Print all initial k icosahedral number
	for n := 1 ; n <= k ; n++ {
		// Formula
		//  n(5n²-5n+2)
		// ——————————————
		//       2

		// Calculate nth icosahedral number
		var result int = (n * (5 * (n * n) - 5 * n + 2)) / 2
		
		// Display calculated result
		fmt.Print(" ", result)
	}
}
func main() {
	
	//  Icosahedral number are
	// —————————————————————————————————————————————
	//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
	//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	//  42276, 47412, 52948, 58899, 65280, 72106, 
	//  79392, 87153, 95404 ... etc

	// k = 10
	icosahedralNo(10)
}

Output

 1 12 48 124 255 456 742 1128 1629 2260
<?php
// Php program for
// Icosahedral number
class IcosahedralNumber
{
	public	function icosahedralNo($k)
	{
		// Print all initial k icosahedral number
		for ($n = 1; $n <= $k; ++$n)
		{
			// Formula
			//  n(5n²-5n+2)
			// ——————————————
			//       2
			// Calculate nth icosahedral number
			$result = (int)(($n * (5 * ($n * $n) - 5 * $n + 2)) / 2);
			// Display calculated result
			echo(" ".$result);
		}
	}
}

function main()
{
	$task = new IcosahedralNumber();
	//  Icosahedral number are
	// —————————————————————————————————————————————
	//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
	//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	//  42276, 47412, 52948, 58899, 65280, 72106, 
	//  79392, 87153, 95404 ... etc
  
	// k = 10
	$task->icosahedralNo(10);
}
main();

Output

 1 12 48 124 255 456 742 1128 1629 2260
// Node JS program for
// Icosahedral number
class IcosahedralNumber
{
	icosahedralNo(k)
	{
		// Print all initial k icosahedral number
		for (var n = 1; n <= k; ++n)
		{
			// Formula
			//  n(5n²-5n+2)
			// ——————————————
			//       2
          
			// Calculate nth icosahedral number
			var result = parseInt((n * (5 * (n * n) - 5 * n + 2)) / 2);
          
			// Display calculated result
			process.stdout.write(" " + result);
		}
	}
}

function main()
{
	var task = new IcosahedralNumber();
	//  Icosahedral number are
	// —————————————————————————————————————————————
	//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
	//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	//  42276, 47412, 52948, 58899, 65280, 72106, 
	//  79392, 87153, 95404 ... etc
  
	// k = 10
	task.icosahedralNo(10);
}
main();

Output

 1 12 48 124 255 456 742 1128 1629 2260
#  Python 3 program for
#  Icosahedral number
class IcosahedralNumber :
	def icosahedralNo(self, k) :
		n = 1
		#  Print all initial k icosahedral number
		while (n <= k) :
			#  Formula
			#   n(5n²-5n+2)
			#  ——————————————
			#        2
            
			#  Calculate nth icosahedral number
			result = int((n * (5 * (n * n) - 5 * n + 2)) / 2)

			#  Display calculated result
			print(" ", result, end = "")
			n += 1
		
	

def main() :
	task = IcosahedralNumber()
	#   Icosahedral number are
	#  —————————————————————————————————————————————
	#   1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
	#   3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	#   16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	#   42276, 47412, 52948, 58899, 65280, 72106, 
	#   79392, 87153, 95404 ... etc
    
	#  k = 10
	task.icosahedralNo(10)

if __name__ == "__main__": main()

Output

  1  12  48  124  255  456  742  1128  1629  2260
#  Ruby program for
#  Icosahedral number
class IcosahedralNumber 
	def icosahedralNo(k) 
		n = 1
		#  Print all initial k icosahedral number
		while (n <= k) 
			#  Formula
			#   n(5n²-5n+2)
			#  ——————————————
			#        2
            
			#  Calculate nth icosahedral number
			result = (n * (5 * (n * n) - 5 * n + 2)) / 2

			#  Display calculated result
			print(" ", result)
			n += 1
		end

	end

end

def main() 
	task = IcosahedralNumber.new()
	#   Icosahedral number are
	#  —————————————————————————————————————————————
	#   1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
	#   3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	#   16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	#   42276, 47412, 52948, 58899, 65280, 72106, 
	#   79392, 87153, 95404 ... etc
	#  k = 10
	task.icosahedralNo(10)
end

main()

Output

 1 12 48 124 255 456 742 1128 1629 2260
// Scala program for
// Icosahedral number
class IcosahedralNumber()
{
	def icosahedralNo(k: Int): Unit = {
		var n: Int = 1;
		// Print all initial k icosahedral number
		while (n <= k)
		{
			// Formula
			//  n(5n²-5n+2)
			// ——————————————
			//       2
          
			// Calculate nth icosahedral number
			var result: Int = (n * (5 * (n * n) - 5 * n + 2)) / 2;
          
			// Display calculated result
			print(" " + result);
			n += 1;
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: IcosahedralNumber = new IcosahedralNumber();
		//  Icosahedral number are
		// —————————————————————————————————————————————
		//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
		//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
		//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
		//  42276, 47412, 52948, 58899, 65280, 72106, 
		//  79392, 87153, 95404 ... etc
		// k = 10
		task.icosahedralNo(10);
	}
}

Output

 1 12 48 124 255 456 742 1128 1629 2260
// Swift 4 program for
// Icosahedral number
class IcosahedralNumber
{
	func icosahedralNo(_ k: Int)
	{
		var n: Int = 1;
		// Print all initial k icosahedral number
		while (n <= k)
		{
			// Formula
			//  n(5n²-5n+2)
			// ——————————————
			//       2
          
			// Calculate nth icosahedral number
			let result: Int = (n * (5 * (n * n) - 5 * n + 2)) / 2;
          
			// Display calculated result
			print(" ", result, terminator: "");
			n += 1;
		}
	}
}
func main()
{
	let task: IcosahedralNumber = IcosahedralNumber();
	//  Icosahedral number are
	// —————————————————————————————————————————————
	//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
	//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	//  42276, 47412, 52948, 58899, 65280, 72106, 
	//  79392, 87153, 95404 ... etc
  
	// k = 10
	task.icosahedralNo(10);
}
main();

Output

  1  12  48  124  255  456  742  1128  1629  2260
// Kotlin program for
// Icosahedral number
class IcosahedralNumber
{
	fun icosahedralNo(k: Int): Unit
	{
		var n: Int = 1;
		// Print all initial k icosahedral number
		while (n <= k)
		{
			// Formula
			//  n(5n²-5n+2)
			// ——————————————
			//       2
          
			// Calculate nth icosahedral number
			val result: Int = (n * (5 * (n * n) - 5 * n + 2)) / 2;
          
			// Display calculated result
			print(" " + result);
			n += 1;
		}
	}
}
fun main(args: Array < String > ): Unit
{
	val task: IcosahedralNumber = IcosahedralNumber();
	//  Icosahedral number are
	// —————————————————————————————————————————————
	//  1, 12, 48, 124, 255, 456, 742, 1128, 1629, 2260 , 
	//  3036, 3972, 5083, 6384, 7890, 9616, 11577, 13788, 
	//  16264, 19020, 22071, 25432, 29118, 33144, 37525, 
	//  42276, 47412, 52948, 58899, 65280, 72106, 
	//  79392, 87153, 95404 ... etc
  
	// k = 10
	task.icosahedralNo(10);
}

Output

 1 12 48 124 255 456 742 1128 1629 2260


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