Centered dodecahedral number

Here given code implementation process.

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

void centeredDodecahedralNo(int k)
{
	// Print all initial k centered dodecahedral number
	for (int n = 0; n < k; ++n)
	{
		// Formula
		//   (2n + 1) (5n² + 5n + 1)
		// Calculate nth dodecahedral number
		int result = (2 *n + 1) *(5 *(n *n) + 5 *n + 1);
		// Display Calculated value
		printf("  %d", result);
	}
}
int main()
{
	// Centered dodecahedral number are
	// —————————————————————————————————————————————
	//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	// 44913, 53585, 63307, 74139, 86141, 99373, 
	// 113895, 129767, 147049, 165801, 186083, 207955, 
	// 231477, 256709, 283711, 312543 ... etc
	// n = 10
	centeredDodecahedralNo(10);
	return 0;
}

Output

  1  33  155  427  909  1661  2743  4215  6137  8569
// Java program for
// Centered dodecahedral number
public class CenteredDodecahedral
{
	public void centeredDodecahedralNo(int k)
	{
		// Print all initial k centered dodecahedral number
		for (int n = 0; n < k; ++n)
		{
			// Formula
			//   (2n + 1) (5n² + 5n + 1)
          
			// Calculate nth dodecahedral number
			int result = (2 * n + 1) * (5 * (n * n) + 5 * n + 1);
          
			// Display Calculated value
			System.out.print(" " + result);
		}
	}
	public static void main(String[] args)
	{
		CenteredDodecahedral task = new CenteredDodecahedral();
		// Centered dodecahedral number are
		// —————————————————————————————————————————————
		//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
		// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
		// 44913, 53585, 63307, 74139, 86141, 99373, 
		// 113895, 129767, 147049, 165801, 186083, 207955, 
		// 231477, 256709, 283711, 312543 ... etc
		// n = 10
		task.centeredDodecahedralNo(10);
	}
}

Output

 1 33 155 427 909 1661 2743 4215 6137 8569
// Include header file
#include <iostream>
using namespace std;
// C++ program for
// Centered dodecahedral number
class CenteredDodecahedral
{
	public: void centeredDodecahedralNo(int k)
	{
		// Print all initial k centered dodecahedral number
		for (int n = 0; n < k; ++n)
		{
			// Formula
			//   (2n + 1) (5n² + 5n + 1)
			// Calculate nth dodecahedral number
			int result = (2 *n + 1) *(5 *(n *n) + 5 *n + 1);
			// Display Calculated value
			cout << " " << result;
		}
	}
};
int main()
{
	CenteredDodecahedral *task = new CenteredDodecahedral();
	// Centered dodecahedral number are
	// —————————————————————————————————————————————
	//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	// 44913, 53585, 63307, 74139, 86141, 99373, 
	// 113895, 129767, 147049, 165801, 186083, 207955, 
	// 231477, 256709, 283711, 312543 ... etc
	// n = 10
	task->centeredDodecahedralNo(10);
	return 0;
}

Output

 1 33 155 427 909 1661 2743 4215 6137 8569
// Include namespace system
using System;
// Csharp program for
// Centered dodecahedral number
public class CenteredDodecahedral
{
	public void centeredDodecahedralNo(int k)
	{
		// Print all initial k centered dodecahedral number
		for (int n = 0; n < k; ++n)
		{
			// Formula
			//   (2n + 1) (5n² + 5n + 1)
			// Calculate nth dodecahedral number
			int result = (2 * n + 1) * (5 * (n * n) + 5 * n + 1);
			// Display Calculated value
			Console.Write(" " + result);
		}
	}
	public static void Main(String[] args)
	{
		CenteredDodecahedral task = new CenteredDodecahedral();
		// Centered dodecahedral number are
		// —————————————————————————————————————————————
		//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
		// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
		// 44913, 53585, 63307, 74139, 86141, 99373, 
		// 113895, 129767, 147049, 165801, 186083, 207955, 
		// 231477, 256709, 283711, 312543 ... etc
		// n = 10
		task.centeredDodecahedralNo(10);
	}
}

Output

 1 33 155 427 909 1661 2743 4215 6137 8569
package main
import "fmt"
// Go program for
// Centered dodecahedral number

func centeredDodecahedralNo(k int) {
	// Print all initial k centered dodecahedral number
	for n := 0 ; n < k ; n++ {
		// Formula
		//   (2n + 1) (5n² + 5n + 1)

		// Calculate nth dodecahedral number
		var result int = (2 * n + 1) * (5 * (n * n) + 5 * n + 1)
		
		// Display Calculated value
		fmt.Print(" ", result)
	}
}
func main() {
	// Centered dodecahedral number are
	// —————————————————————————————————————————————
	//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	// 44913, 53585, 63307, 74139, 86141, 99373, 
	// 113895, 129767, 147049, 165801, 186083, 207955, 
	// 231477, 256709, 283711, 312543 ... etc
	// n = 10
	centeredDodecahedralNo(10)
}

Output

 1 33 155 427 909 1661 2743 4215 6137 8569
<?php
// Php program for
// Centered dodecahedral number
class CenteredDodecahedral
{
	public	function centeredDodecahedralNo($k)
	{
		// Print all initial k centered dodecahedral number
		for ($n = 0; $n < $k; ++$n)
		{
			// Formula
			//   (2n + 1) (5n² + 5n + 1)
          
			// Calculate nth dodecahedral number
			$result = (2 * $n + 1) * (5 * ($n * $n) + 5 * $n + 1);
          
			// Display Calculated value
			echo(" ".$result);
		}
	}
}

function main()
{
	$task = new CenteredDodecahedral();
	// Centered dodecahedral number are
	// —————————————————————————————————————————————
	//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	// 44913, 53585, 63307, 74139, 86141, 99373, 
	// 113895, 129767, 147049, 165801, 186083, 207955, 
	// 231477, 256709, 283711, 312543 ... etc
	// n = 10
	$task->centeredDodecahedralNo(10);
}
main();

Output

 1 33 155 427 909 1661 2743 4215 6137 8569
// Node JS program for
// Centered dodecahedral number
class CenteredDodecahedral
{
	centeredDodecahedralNo(k)
	{
		// Print all initial k centered dodecahedral number
		for (var n = 0; n < k; ++n)
		{
			// Formula
			//   (2n + 1) (5n² + 5n + 1)
          
			// Calculate nth dodecahedral number
			var result = (2 * n + 1) * (5 * (n * n) + 5 * n + 1);
          
			// Display Calculated value
			process.stdout.write(" " + result);
		}
	}
}

function main()
{
	var task = new CenteredDodecahedral();
	// Centered dodecahedral number are
	// —————————————————————————————————————————————
	//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	// 44913, 53585, 63307, 74139, 86141, 99373, 
	// 113895, 129767, 147049, 165801, 186083, 207955, 
	// 231477, 256709, 283711, 312543 ... etc
	// n = 10
	task.centeredDodecahedralNo(10);
}
main();

Output

 1 33 155 427 909 1661 2743 4215 6137 8569
#  Python 3 program for
#  Centered dodecahedral number
class CenteredDodecahedral :
	def centeredDodecahedralNo(self, k) :
		n = 0
		#  Print all initial k centered dodecahedral number
		while (n < k) :
			#  Formula
			#    (2n + 1) (5n² + 5n + 1)
			#  Calculate nth dodecahedral number
			result = (2 * n + 1) * (5 * (n * n) + 5 * n + 1)
			#  Display Calculated value
			print(" ", result, end = "")
			n += 1
		
	

def main() :
	task = CenteredDodecahedral()
	#  Centered dodecahedral number are
	#  —————————————————————————————————————————————
	#   1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	#  8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	#  44913, 53585, 63307, 74139, 86141, 99373, 
	#  113895, 129767, 147049, 165801, 186083, 207955, 
	#  231477, 256709, 283711, 312543 ... etc
	#  n = 10
	task.centeredDodecahedralNo(10)

if __name__ == "__main__": main()

Output

  1  33  155  427  909  1661  2743  4215  6137  8569
#  Ruby program for
#  Centered dodecahedral number
class CenteredDodecahedral 
	def centeredDodecahedralNo(k) 
		n = 0
		#  Print all initial k centered dodecahedral number
		while (n < k) 
			#  Formula
			#    (2n + 1) (5n² + 5n + 1)
			#  Calculate nth dodecahedral number
			result = (2 * n + 1) * (5 * (n * n) + 5 * n + 1)
			#  Display Calculated value
			print(" ", result)
			n += 1
		end

	end

end

def main() 
	task = CenteredDodecahedral.new()
	#  Centered dodecahedral number are
	#  —————————————————————————————————————————————
	#   1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	#  8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	#  44913, 53585, 63307, 74139, 86141, 99373, 
	#  113895, 129767, 147049, 165801, 186083, 207955, 
	#  231477, 256709, 283711, 312543 ... etc
	#  n = 10
	task.centeredDodecahedralNo(10)
end

main()

Output

 1 33 155 427 909 1661 2743 4215 6137 8569
// Scala program for
// Centered dodecahedral number
class CenteredDodecahedral()
{
	def centeredDodecahedralNo(k: Int): Unit = {
		var n: Int = 0;
		// Print all initial k centered dodecahedral number
		while (n < k)
		{
			// Formula
			//   (2n + 1) (5n² + 5n + 1)
          
			// Calculate nth dodecahedral number
			var result: Int = (2 * n + 1) * (5 * (n * n) + 5 * n + 1);
          
			// Display Calculated value
			print(" " + result);
			n += 1;
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: CenteredDodecahedral = new CenteredDodecahedral();
		// Centered dodecahedral number are
		// —————————————————————————————————————————————
		//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
		// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
		// 44913, 53585, 63307, 74139, 86141, 99373, 
		// 113895, 129767, 147049, 165801, 186083, 207955, 
		// 231477, 256709, 283711, 312543 ... etc
		// n = 10
		task.centeredDodecahedralNo(10);
	}
}

Output

 1 33 155 427 909 1661 2743 4215 6137 8569
// Swift 4 program for
// Centered dodecahedral number
class CenteredDodecahedral
{
	func centeredDodecahedralNo(_ k: Int)
	{
		var n: Int = 0;
		// Print all initial k centered dodecahedral number
		while (n < k)
		{
			// Formula
			//   (2n + 1) (5n² + 5n + 1)
          
			// Calculate nth dodecahedral number
			let result: Int = (2 * n + 1) * (5 * (n * n) + 5 * n + 1);
          
			// Display Calculated value
			print(" ", result, terminator: "");
			n += 1;
		}
	}
}
func main()
{
	let task: CenteredDodecahedral = CenteredDodecahedral();
	// Centered dodecahedral number are
	// —————————————————————————————————————————————
	//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	// 44913, 53585, 63307, 74139, 86141, 99373, 
	// 113895, 129767, 147049, 165801, 186083, 207955, 
	// 231477, 256709, 283711, 312543 ... etc
	// n = 10
	task.centeredDodecahedralNo(10);
}
main();

Output

  1  33  155  427  909  1661  2743  4215  6137  8569
// Kotlin program for
// Centered dodecahedral number
class CenteredDodecahedral
{
	fun centeredDodecahedralNo(k: Int): Unit
	{
		var n: Int = 0;
		// Print all initial k centered dodecahedral number
		while (n < k)
		{
			// Formula
			//   (2n + 1) (5n² + 5n + 1)
          
			// Calculate nth dodecahedral number
			val result: Int = (2 * n + 1) * (5 * (n * n) + 5 * n + 1);
          
			// Display Calculated value
			print(" " + result);
			n += 1;
		}
	}
}
fun main(args: Array < String > ): Unit
{
	val task: CenteredDodecahedral = CenteredDodecahedral();
	// Centered dodecahedral number are
	// —————————————————————————————————————————————
	//  1, 33, 155, 427, 909, 1661, 2743, 4215, 6137, 
	// 8569, 11571, 15203, 19525, 24597, 30479, 37231, 
	// 44913, 53585, 63307, 74139, 86141, 99373, 
	// 113895, 129767, 147049, 165801, 186083, 207955, 
	// 231477, 256709, 283711, 312543 ... etc
	// n = 10
	task.centeredDodecahedralNo(10);
}

Output

 1 33 155 427 909 1661 2743 4215 6137 8569


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