Centered icosahedral number

Here given code implementation process.

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

void centeredIcosahedralNo(int k)
{
	// Print all initial k centered icosahedral number
	for (int n = 0; n < k; ++n)
	{
		//   Formula
		//   (2n + 1) (5n² + 5n + 3) 
		//   ——————————————————————
		//             3
      
		// Calculate nth icosahedral number
		int result = ((2 *n + 1) *(5 *(n *n) + 5 *n + 3)) / 3;
      
		// Display Calculated value
		printf("  %d", result);
	}
}
int main()
{
	// Centered icosahedral numbers are
	// —————————————————————————————————————————————
	//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	//   2869, 3871, 5083, 6525 ... etc
	//  Test k = 10
	centeredIcosahedralNo(10);
	return 0;
}

Output

  1  13  55  147  309  561  923  1415  2057  2869
// Java program for
// Centered icosahedral number
public class CenteredIcosahedral
{
	public void centeredIcosahedralNo(int k)
	{
		// Print all initial k centered icosahedral number
		for (int n = 0; n < k; ++n)
		{
			//   Formula
			//   (2n + 1) (5n² + 5n + 3) 
			//   ——————————————————————
			//             3
          
			// Calculate nth icosahedral number
			int result = ((2 * n + 1) * (5 * (n * n) + 5 * n + 3)) / 3;
          
			// Display Calculated value
			System.out.print(" " + result);
		}
	}
	public static void main(String[] args)
	{
		CenteredIcosahedral task = new CenteredIcosahedral();
		// Centered icosahedral numbers are
		// —————————————————————————————————————————————
		//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
		//   2869, 3871, 5083, 6525 ... etc
		//  Test k = 10
		task.centeredIcosahedralNo(10);
	}
}

Output

 1 13 55 147 309 561 923 1415 2057 2869
// Include header file
#include <iostream>
using namespace std;
// C++ program for
// Centered icosahedral number

class CenteredIcosahedral
{
	public: void centeredIcosahedralNo(int k)
	{
		// Print all initial k centered icosahedral number
		for (int n = 0; n < k; ++n)
		{
			//   Formula
			//   (2n + 1) (5n² + 5n + 3) 
			//   ——————————————————————
			//             3
          
			// Calculate nth icosahedral number
			int result = ((2 *n + 1) *(5 *(n *n) + 5 *n + 3)) / 3;
          
			// Display Calculated value
			cout << " " << result;
		}
	}
};
int main()
{
	CenteredIcosahedral *task = new CenteredIcosahedral();
	// Centered icosahedral numbers are
	// —————————————————————————————————————————————
	//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	//   2869, 3871, 5083, 6525 ... etc
	//  Test k = 10
	task->centeredIcosahedralNo(10);
	return 0;
}

Output

 1 13 55 147 309 561 923 1415 2057 2869
// Include namespace system
using System;
// Csharp program for
// Centered icosahedral number
public class CenteredIcosahedral
{
	public void centeredIcosahedralNo(int k)
	{
		// Print all initial k centered icosahedral number
		for (int n = 0; n < k; ++n)
		{
			//   Formula
			//   (2n + 1) (5n² + 5n + 3) 
			//   ——————————————————————
			//             3
          
			// Calculate nth icosahedral number
			int result = ((2 * n + 1) * (5 * (n * n) + 5 * n + 3)) / 3;
          
			// Display Calculated value
			Console.Write(" " + result);
		}
	}
	public static void Main(String[] args)
	{
		CenteredIcosahedral task = new CenteredIcosahedral();
		// Centered icosahedral numbers are
		// —————————————————————————————————————————————
		//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
		//   2869, 3871, 5083, 6525 ... etc
		//  Test k = 10
		task.centeredIcosahedralNo(10);
	}
}

Output

 1 13 55 147 309 561 923 1415 2057 2869
package main
import "fmt"
// Go program for
// Centered icosahedral number

func centeredIcosahedralNo(k int) {
	// Print all initial k centered icosahedral number
	for n := 0 ; n < k ; n++ {
		//   Formula
		//   (2n + 1) (5n² + 5n + 3) 
		//   ——————————————————————
		//             3
      
		// Calculate nth icosahedral number
		var result int = ((2 * n + 1) * 
                          (5 * (n * n) + 5 * n + 3)) / 3
      
		// Display Calculated value
		fmt.Print(" ", result)
	}
}
func main() {

	// Centered icosahedral numbers are
	// —————————————————————————————————————————————
	//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	//   2869, 3871, 5083, 6525 ... etc
	
	//  Test k = 10
	centeredIcosahedralNo(10)
}

Output

 1 13 55 147 309 561 923 1415 2057 2869
<?php
// Php program for
// Centered icosahedral number
class CenteredIcosahedral
{
	public	function centeredIcosahedralNo($k)
	{
		// Print all initial k centered icosahedral number
		for ($n = 0; $n < $k; ++$n)
		{
			//   Formula
			//   (2n + 1) (5n² + 5n + 3) 
			//   ——————————————————————
			//             3
          
			// Calculate nth icosahedral number
			$result = (int)(((2 * $n + 1) * 
                             (5 * ($n * $n) + 5 * $n + 3)) / 3);
          
			// Display Calculated value
			echo(" ".$result);
		}
	}
}

function main()
{
	$task = new CenteredIcosahedral();
	// Centered icosahedral numbers are
	// —————————————————————————————————————————————
	//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	//   2869, 3871, 5083, 6525 ... etc
	//  Test k = 10
	$task->centeredIcosahedralNo(10);
}
main();

Output

 1 13 55 147 309 561 923 1415 2057 2869
// Node JS program for
// Centered icosahedral number
class CenteredIcosahedral
{
	centeredIcosahedralNo(k)
	{
		// Print all initial k centered icosahedral number
		for (var n = 0; n < k; ++n)
		{
			//   Formula
			//   (2n + 1) (5n² + 5n + 3) 
			//   ——————————————————————
			//             3
			// Calculate nth icosahedral number
			var result = parseInt(((2 * n + 1) * 
                                   (5 * (n * n) + 5 * n + 3)) / 3);
			// Display Calculated value
			process.stdout.write(" " + result);
		}
	}
}

function main()
{
	var task = new CenteredIcosahedral();
	// Centered icosahedral numbers are
	// —————————————————————————————————————————————
	//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	//   2869, 3871, 5083, 6525 ... etc
	//  Test k = 10
	task.centeredIcosahedralNo(10);
}
main();

Output

 1 13 55 147 309 561 923 1415 2057 2869
#  Python 3 program for
#  Centered icosahedral number
class CenteredIcosahedral :
	def centeredIcosahedralNo(self, k) :
		n = 0
		#  Print all initial k centered icosahedral number
		while (n < k) :
			#    Formula
			#    (2n + 1) (5n² + 5n + 3) 
			#    ——————————————————————
			#              3
			#  Calculate nth icosahedral number
			result = int(((2 * n + 1) * 
                          (5 * (n * n) + 5 * n + 3)) / 3)
			#  Display Calculated value
			print(" ", result, end = "")
			n += 1
		
	

def main() :
	task = CenteredIcosahedral()
	#  Centered icosahedral numbers are
	#  —————————————————————————————————————————————
	#    1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	#    2869, 3871, 5083, 6525 ... etc
	#   Test k = 10
	task.centeredIcosahedralNo(10)

if __name__ == "__main__": main()

Output

  1  13  55  147  309  561  923  1415  2057  2869
#  Ruby program for
#  Centered icosahedral number
class CenteredIcosahedral 
	def centeredIcosahedralNo(k) 
		n = 0
		#  Print all initial k centered icosahedral number
		while (n < k) 
			#    Formula
			#    (2n + 1) (5n² + 5n + 3) 
			#    ——————————————————————
			#              3
            
			#  Calculate nth icosahedral number
			result = ((2 * n + 1) * (5 * (n * n) + 5 * n + 3)) / 3

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

	end

end

def main() 
	task = CenteredIcosahedral.new()
	#  Centered icosahedral numbers are
	#  —————————————————————————————————————————————
	#    1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	#    2869, 3871, 5083, 6525 ... etc
    
	#   Test k = 10
	task.centeredIcosahedralNo(10)
end

main()

Output

 1 13 55 147 309 561 923 1415 2057 2869
// Scala program for
// Centered icosahedral number
class CenteredIcosahedral()
{
	def centeredIcosahedralNo(k: Int): Unit = {
		var n: Int = 0;
		// Print all initial k centered icosahedral number
		while (n < k)
		{
			//   Formula
			//   (2n + 1) (5n² + 5n + 3) 
			//   ——————————————————————
			//             3
          
			// Calculate nth icosahedral number
			var result: Int = ((2 * n + 1) * 
                               (5 * (n * n) + 5 * n + 3)) / 3;
          
			// Display Calculated value
			print(" " + result);
			n += 1;
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: CenteredIcosahedral = new CenteredIcosahedral();
		// Centered icosahedral numbers are
		// —————————————————————————————————————————————
		//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
		//   2869, 3871, 5083, 6525 ... etc
  
		//  Test k = 10
		task.centeredIcosahedralNo(10);
	}
}

Output

 1 13 55 147 309 561 923 1415 2057 2869
// Swift 4 program for
// Centered icosahedral number
class CenteredIcosahedral
{
	func centeredIcosahedralNo(_ k: Int)
	{
		var n: Int = 0;
		// Print all initial k centered icosahedral number
		while (n < k)
		{
			//   Formula
			//   (2n + 1) (5n² + 5n + 3) 
			//   ——————————————————————
			//             3
          
			// Calculate nth icosahedral number
			let result: Int = ((2 * n + 1) * 
                               (5 * (n * n) + 5 * n + 3)) / 3;
          
			// Display Calculated value
			print(" ", result, terminator: "");
			n += 1;
		}
	}
}
func main()
{
	let task: CenteredIcosahedral = CenteredIcosahedral();
	// Centered icosahedral numbers are
	// —————————————————————————————————————————————
	//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	//   2869, 3871, 5083, 6525 ... etc
  
	//  Test k = 10
	task.centeredIcosahedralNo(10);
}
main();

Output

  1  13  55  147  309  561  923  1415  2057  2869
// Kotlin program for
// Centered icosahedral number
class CenteredIcosahedral
{
	fun centeredIcosahedralNo(k: Int): Unit
	{
		var n: Int = 0;
		// Print all initial k centered icosahedral number
		while (n < k)
		{
			//   Formula
			//   (2n + 1) (5n² + 5n + 3) 
			//   ——————————————————————
			//             3
          
			// Calculate nth icosahedral number
			val result: Int = ((2 * n + 1) * 
                               (5 * (n * n) + 5 * n + 3)) / 3;
          
			// Display Calculated value
			print(" " + result);
			n += 1;
		}
	}
}
fun main(args: Array < String > ): Unit
{
	val task: CenteredIcosahedral = CenteredIcosahedral();
	// Centered icosahedral numbers are
	// —————————————————————————————————————————————
	//   1, 13, 55, 147, 309, 561, 923, 1415, 2057, 
	//   2869, 3871, 5083, 6525 ... etc
  
	//  Test k = 10
	task.centeredIcosahedralNo(10);
}

Output

 1 13 55 147 309 561 923 1415 2057 2869

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