Centered Dodecagonal Number

Here given code implementation process.

// C Program for
// Centered Dodecagonal Number
#include <stdio.h>

void centeredDodecagonalNo(int k)
{
	int result = 0;
	// Print all initial k centered Dodecagonal number
	for (int n = 0; n < k; ++n)
	{
		// Centered dodecagonal formula =  5n²+5n+ 1
		result = ((5 *(n *n) + (5 *n) + 1));
		// Display value
		printf("  %d", result);
	}
}
int main()
{
	// Centered Dodecagonal numbers
	// --------------------------------------
	// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
	// 451, 551, 661, 781, 9119 .. etc
	// Test 
	// k  = 10
	centeredDodecagonalNo(10);
	return 0;
}

Output

  1  11  31  61  101  151  211  281  361  451
// Java program for
// Centered Dodecagonal Number
public class DodecagonalNumber
{
	public void centeredDodecagonalNo(int k)
	{
		int result = 0;
		// Print all initial k centered dodecagonal number
		for (int n = 0; n < k; ++n)
		{
			// Centered dodecagonal 
			// formula =  5n²+5n+ 1
            
            // Calculate result
			result = ((5 * (n * n) + (5 * n) + 1));
          
			// Display calculated result
			System.out.print(" " + result);
		}
	}
	public static void main(String[] args)
	{
		DodecagonalNumber task = new DodecagonalNumber();
		// Centered Dodecagonal numbers
		// --------------------------------------
		// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
		// 451, 551, 661, 781, 9119 .. etc
      
		// Test 
		// k  = 10
		task.centeredDodecagonalNo(10);
	}
}

Output

 1 11 31 61 101 151 211 281 361 451
// Include header file
#include <iostream>
using namespace std;
// C++ program for
// Centered Dodecagonal Number

class DodecagonalNumber
{
	public: void centeredDodecagonalNo(int k)
	{
		int result = 0;
		// Print all initial k centered dodecagonal number
		for (int n = 0; n < k; ++n)
		{
			// Centered dodecagonal 
			// formula =  5n²+5n+ 1
          
			// Calculate result
			result = ((5 *(n *n) + (5 *n) + 1));
          
			// Display calculated result
			cout << " " << result;
		}
	}
};
int main()
{
	DodecagonalNumber *task = new DodecagonalNumber();
	// Centered Dodecagonal numbers
	// --------------------------------------
	// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
	// 451, 551, 661, 781, 9119 .. etc
  
	// Test 
	// k  = 10
	task->centeredDodecagonalNo(10);
	return 0;
}

Output

 1 11 31 61 101 151 211 281 361 451
// Include namespace system
using System;
// Csharp program for
// Centered Dodecagonal Number
public class DodecagonalNumber
{
	public void centeredDodecagonalNo(int k)
	{
		int result = 0;
		// Print all initial k centered dodecagonal number
		for (int n = 0; n < k; ++n)
		{
			// Centered dodecagonal 
			// formula =  5n²+5n+ 1
          
			// Calculate result
			result = ((5 * (n * n) + (5 * n) + 1));
          
			// Display calculated result
			Console.Write(" " + result);
		}
	}
	public static void Main(String[] args)
	{
		DodecagonalNumber task = new DodecagonalNumber();
		// Centered Dodecagonal numbers
		// --------------------------------------
		// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
		// 451, 551, 661, 781, 9119 .. etc
      
		// Test 
		// k  = 10
		task.centeredDodecagonalNo(10);
	}
}

Output

 1 11 31 61 101 151 211 281 361 451
package main
import "fmt"
// Go program for
// Centered Dodecagonal Number

func centeredDodecagonalNo(k int) {
	var result int = 0
	// Print all initial k centered dodecagonal number
	for n := 0 ; n < k ; n++ {
		// Centered dodecagonal 
		// formula =  5n²+5n+ 1
		// Calculate result
		result = ((5 * (n * n) + (5 * n) + 1))
		// Display calculated result
		fmt.Print(" ", result)
	}
}
func main() {
	// Centered Dodecagonal numbers
	// --------------------------------------
	// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
	// 451, 551, 661, 781, 9119 .. etc
  
	// Test 
	// k  = 10
	centeredDodecagonalNo(10)
}

Output

 1 11 31 61 101 151 211 281 361 451
<?php
// Php program for
// Centered Dodecagonal Number
class DodecagonalNumber
{
	public	function centeredDodecagonalNo($k)
	{
		$result = 0;
		// Print all initial k centered dodecagonal number
		for ($n = 0; $n < $k; ++$n)
		{
			// Centered dodecagonal 
			// formula =  5n²+5n+ 1
          
			// Calculate result
			$result = ((5 * ($n * $n) + (5 * $n) + 1));
          
			// Display calculated result
			echo(" ".$result);
		}
	}
}

function main()
{
	$task = new DodecagonalNumber();
	// Centered Dodecagonal numbers
	// --------------------------------------
	// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
	// 451, 551, 661, 781, 9119 .. etc
	// Test 
	// k  = 10
	$task->centeredDodecagonalNo(10);
}
main();

Output

 1 11 31 61 101 151 211 281 361 451
// Node JS program for
// Centered Dodecagonal Number
class DodecagonalNumber
{
	centeredDodecagonalNo(k)
	{
		var result = 0;
		// Print all initial k centered dodecagonal number
		for (var n = 0; n < k; ++n)
		{
			// Centered dodecagonal 
			// formula =  5n²+5n+ 1
          
			// Calculate result
			result = ((5 * (n * n) + (5 * n) + 1));
          
			// Display calculated result
			process.stdout.write(" " + result);
		}
	}
}

function main()
{
	var task = new DodecagonalNumber();
	// Centered Dodecagonal numbers
	// --------------------------------------
	// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
	// 451, 551, 661, 781, 9119 .. etc
  
	// Test 
	// k  = 10
	task.centeredDodecagonalNo(10);
}
main();

Output

 1 11 31 61 101 151 211 281 361 451
#  Python 3 program for
#  Centered Dodecagonal Number
class DodecagonalNumber :
	def centeredDodecagonalNo(self, k) :
		result = 0
		n = 0
		#  Print all initial k centered dodecagonal number
		while (n < k) :
			#  Centered dodecagonal 
			#  formula =  5n²+5n+ 1
            
			#  Calculate result
			result = ((5 * (n * n) + (5 * n) + 1))

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

def main() :
	task = DodecagonalNumber()
	#  Centered Dodecagonal numbers
	#  --------------------------------------
	#  1, 11, 31, 61, 101, 151, 211, 281, 361, 
	#  451, 551, 661, 781, 9119 .. etc
    
	#  Test 
	#  k  = 10
	task.centeredDodecagonalNo(10)

if __name__ == "__main__": main()

Output

  1  11  31  61  101  151  211  281  361  451
#  Ruby program for
#  Centered Dodecagonal Number
class DodecagonalNumber 
	def centeredDodecagonalNo(k) 
		result = 0
		n = 0
		#  Print all initial k centered dodecagonal number
		while (n < k) 
			#  Centered dodecagonal 
			#  formula =  5n²+5n+ 1
            
			#  Calculate result
			result = ((5 * (n * n) + (5 * n) + 1))

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

	end

end

def main() 
	task = DodecagonalNumber.new()
	#  Centered Dodecagonal numbers
	#  --------------------------------------
	#  1, 11, 31, 61, 101, 151, 211, 281, 361, 
	#  451, 551, 661, 781, 9119 .. etc
	#  Test 
	#  k  = 10
	task.centeredDodecagonalNo(10)
end

main()

Output

 1 11 31 61 101 151 211 281 361 451
// Scala program for
// Centered Dodecagonal Number
class DodecagonalNumber()
{
	def centeredDodecagonalNo(k: Int): Unit = {
		var result: Int = 0;
		var n: Int = 0;
		// Print all initial k centered dodecagonal number
		while (n < k)
		{
			// Centered dodecagonal 
			// formula =  5n²+5n+ 1
          
			// Calculate result
			result = ((5 * (n * n) + (5 * n) + 1));
          
			// Display calculated result
			print(" " + result);
			n += 1;
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: DodecagonalNumber = new DodecagonalNumber();
		// Centered Dodecagonal numbers
		// --------------------------------------
		// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
		// 451, 551, 661, 781, 9119 .. etc
		// Test 
		// k  = 10
		task.centeredDodecagonalNo(10);
	}
}

Output

 1 11 31 61 101 151 211 281 361 451
// Swift 4 program for
// Centered Dodecagonal Number
class DodecagonalNumber
{
	func centeredDodecagonalNo(_ k: Int)
	{
		var result: Int = 0;
		var n: Int = 0;
		// Print all initial k centered dodecagonal number
		while (n < k)
		{
			// Centered dodecagonal 
			// formula =  5n²+5n+ 1
          
			// Calculate result
			result = ((5 * (n * n) + (5 * n) + 1));
          
			// Display calculated result
			print(" ", result, terminator: "");
			n += 1;
		}
	}
}
func main()
{
	let task: DodecagonalNumber = DodecagonalNumber();
	// Centered Dodecagonal numbers
	// --------------------------------------
	// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
	// 451, 551, 661, 781, 9119 .. etc
	// Test 
	// k  = 10
	task.centeredDodecagonalNo(10);
}
main();

Output

  1  11  31  61  101  151  211  281  361  451
// Kotlin program for
// Centered Dodecagonal Number
class DodecagonalNumber
{
	fun centeredDodecagonalNo(k: Int): Unit
	{
		var result: Int ;
		var n: Int = 0;
		// Print all initial k centered dodecagonal number
		while (n < k)
		{
			// Centered dodecagonal 
			// formula =  5n²+5n+ 1
          
			// Calculate result
			result = ((5 * (n * n) + (5 * n) + 1));
          
			// Display calculated result
			print(" " + result);
			n += 1;
		}
	}
}
fun main(args: Array < String > ): Unit
{
	val task: DodecagonalNumber = DodecagonalNumber();
	// Centered Dodecagonal numbers
	// --------------------------------------
	// 1, 11, 31, 61, 101, 151, 211, 281, 361, 
	// 451, 551, 661, 781, 9119 .. etc
  
	// Test 
	// k  = 10
	task.centeredDodecagonalNo(10);
}

Output

 1 11 31 61 101 151 211 281 361 451


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