Dodecagonal number

Here given code implementation process.

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

void dodecagonalNo(int k)
{
	// Print all initial k dodecagonal number
	for (int n = 1; n <= k; ++n)
	{
		// Formula
		// (5n² - 4n )
      
		// Calculate nth dodecagonal number
		int result = (5 * (n * n) - 4 * n);
      
		// Display Calculated value
		printf("  %d", result);
	}
}
int main()
{
	// Dodecagonal number are
	// —————————————————————————————————————————————
	// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	// 5985, 6336, 6697, 7068 ... etc
  
	// Test k = 10
	dodecagonalNo(10);
	return 0;
}

Output

  1  12  33  64  105  156  217  288  369  460
// Java program for
// Dodecagonal number
public class DodecagonalNumber
{
	public void dodecagonalNo(int k)
	{
		// Print all initial k dodecagonal number
		for (int n = 1; n <= k; ++n)
		{
			// Formula
			// (5n² - 4n )
          
			// Calculate nth dodecagonal number
			int result = (5 * (n * n) - 4 * n);
          
			// Display Calculated value
			System.out.print(" " + result);
		}
	}
	public static void main(String[] args)
	{
		DodecagonalNumber task = new DodecagonalNumber();
		// Dodecagonal number are
		// —————————————————————————————————————————————
		// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
		// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
		// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
		// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
		// 5985, 6336, 6697, 7068 ... etc
      
		// Test k = 10
		task.dodecagonalNo(10);
	}
}

Output

 1 12 33 64 105 156 217 288 369 460
// Include header file
#include <iostream>
using namespace std;
// C++ program for
// Dodecagonal number

class DodecagonalNumber
{
	public: void dodecagonalNo(int k)
	{
		// Print all initial k dodecagonal number
		for (int n = 1; n <= k; ++n)
		{
			// Formula
			// (5n² - 4n )
          
			// Calculate nth dodecagonal number
			int result = (5 *(n *n) - 4 *n);
          
			// Display Calculated value
			cout << " " << result;
		}
	}
};
int main()
{
	DodecagonalNumber *task = new DodecagonalNumber();
	// Dodecagonal number are
	// —————————————————————————————————————————————
	// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	// 5985, 6336, 6697, 7068 ... etc
  
	// Test k = 10
	task->dodecagonalNo(10);
	return 0;
}

Output

 1 12 33 64 105 156 217 288 369 460
// Include namespace system
using System;
// Csharp program for
// Dodecagonal number
public class DodecagonalNumber
{
	public void dodecagonalNo(int k)
	{
		// Print all initial k dodecagonal number
		for (int n = 1; n <= k; ++n)
		{
			// Formula
			// (5n² - 4n )
          
			// Calculate nth dodecagonal number
			int result = (5 * (n * n) - 4 * n);
          
			// Display Calculated value
			Console.Write(" " + result);
		}
	}
	public static void Main(String[] args)
	{
		DodecagonalNumber task = new DodecagonalNumber();
		// Dodecagonal number are
		// —————————————————————————————————————————————
		// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
		// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
		// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
		// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
		// 5985, 6336, 6697, 7068 ... etc
      
		// Test k = 10
		task.dodecagonalNo(10);
	}
}

Output

 1 12 33 64 105 156 217 288 369 460
package main
import "fmt"
// Go program for
// Dodecagonal number

func dodecagonalNo(k int) {
	// Print all initial k dodecagonal number
	for n := 1 ; n <= k ; n++ {
		// Formula
		// (5n² - 4n )

		// Calculate nth dodecagonal number
		var result int = (5 * (n * n) - 4 * n)

		// Display Calculated value
		fmt.Print(" ", result)
	}
}
func main() {
	// Dodecagonal number are
	// —————————————————————————————————————————————
	// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	// 5985, 6336, 6697, 7068 ... etc
	
	// Test k = 10
	dodecagonalNo(10)
}

Output

 1 12 33 64 105 156 217 288 369 460
<?php
// Php program for
// Dodecagonal number
class DodecagonalNumber
{
	public	function dodecagonalNo($k)
	{
		// Print all initial k dodecagonal number
		for ($n = 1; $n <= $k; ++$n)
		{
			// Formula
			// (5n² - 4n )
          
			// Calculate nth dodecagonal number
			$result = (5 * ($n * $n) - 4 * $n);
          
			// Display Calculated value
			echo(" ".$result);
		}
	}
}

function main()
{
	$task = new DodecagonalNumber();
	// Dodecagonal number are
	// —————————————————————————————————————————————
	// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	// 5985, 6336, 6697, 7068 ... etc
  
	// Test k = 10
	$task->dodecagonalNo(10);
}
main();

Output

 1 12 33 64 105 156 217 288 369 460
// Node JS program for
// Dodecagonal number
class DodecagonalNumber
{
	dodecagonalNo(k)
	{
		// Print all initial k dodecagonal number
		for (var n = 1; n <= k; ++n)
		{
			// Formula
			// (5n² - 4n)
          
			// Calculate nth dodecagonal number
			var result = (5 * (n * n) - 4 * n);
          
			// Display Calculated value
			process.stdout.write(" " + result);
		}
	}
}

function main()
{
	var task = new DodecagonalNumber();
	// Dodecagonal number are
	// —————————————————————————————————————————————
	// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	// 5985, 6336, 6697, 7068 ... etc
	// Test k = 10
	task.dodecagonalNo(10);
}
main();

Output

 1 12 33 64 105 156 217 288 369 460
#  Python 3 program for
#  Dodecagonal number
class DodecagonalNumber :
	def dodecagonalNo(self, k) :
		n = 1
		#  Print all initial k dodecagonal number
		while (n <= k) :
			#  Formula
			#  (5n² - 4n)
            
			#  Calculate nth dodecagonal number
			result = (5 * (n * n) - 4 * n)

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

def main() :
	task = DodecagonalNumber()
	#  Dodecagonal number are
	#  —————————————————————————————————————————————
	#  1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	#  672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	#  1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	#  3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	#  5985, 6336, 6697, 7068 ... etc
    
	#  Test k = 10
	task.dodecagonalNo(10)

if __name__ == "__main__": main()

Output

  1  12  33  64  105  156  217  288  369  460
#  Ruby program for
#  Dodecagonal number
class DodecagonalNumber 
	def dodecagonalNo(k) 
		n = 1
		#  Print all initial k dodecagonal number
		while (n <= k) 
			#  Formula
			#  (5n² - 4n)
            
			#  Calculate nth dodecagonal number
			result = (5 * (n * n) - 4 * n)

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

	end

end

def main() 
	task = DodecagonalNumber.new()
	#  Dodecagonal number are
	#  —————————————————————————————————————————————
	#  1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	#  672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	#  1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	#  3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	#  5985, 6336, 6697, 7068 ... etc
    
	#  Test k = 10
	task.dodecagonalNo(10)
end

main()

Output

 1 12 33 64 105 156 217 288 369 460
// Scala program for
// Dodecagonal number
class DodecagonalNumber()
{
	def dodecagonalNo(k: Int): Unit = {
		var n: Int = 1;
		// Print all initial k dodecagonal number
		while (n <= k)
		{
			// Formula
			// (5n² - 4n)
          
			// Calculate nth dodecagonal number
			var result: Int = (5 * (n * n) - 4 * n);
          
			// Display Calculated value
			print(" " + result);
			n += 1;
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: DodecagonalNumber = new DodecagonalNumber();
		// Dodecagonal number are
		// —————————————————————————————————————————————
		// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
		// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
		// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
		// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
		// 5985, 6336, 6697, 7068 ... etc
  
		// Test k = 10
		task.dodecagonalNo(10);
	}
}

Output

 1 12 33 64 105 156 217 288 369 460
// Swift 4 program for
// Dodecagonal number
class DodecagonalNumber
{
	func dodecagonalNo(_ k: Int)
	{
		var n: Int = 1;
		// Print all initial k dodecagonal number
		while (n <= k)
		{
			// Formula
			// (5n² - 4n)
          
			// Calculate nth dodecagonal number
			let result: Int = (5 * (n * n) - 4 * n);
          
			// Display Calculated value
			print(" ", result, terminator: "");
			n += 1;
		}
	}
}
func main()
{
	let task: DodecagonalNumber = DodecagonalNumber();
	// Dodecagonal number are
	// —————————————————————————————————————————————
	// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	// 5985, 6336, 6697, 7068 ... etc
  
	// Test k = 10
	task.dodecagonalNo(10);
}
main();

Output

  1  12  33  64  105  156  217  288  369  460
// Kotlin program for
// Dodecagonal number
class DodecagonalNumber
{
	fun dodecagonalNo(k: Int): Unit
	{
		var n: Int = 1;
		// Print all initial k dodecagonal number
		while (n <= k)
		{
			// Formula
			// (5n² - 4n)
          
			// Calculate nth dodecagonal number
			val result: Int = (5 * (n * n) - 4 * n);
          
			// Display Calculated value
			print(" " + result);
			n += 1;
		}
	}
}
fun main(args: Array < String > ): Unit
{
	val task: DodecagonalNumber = DodecagonalNumber();
	// Dodecagonal number are
	// —————————————————————————————————————————————
	// 1, 12, 33, 64, 105, 156, 217, 288, 369, 460, 561, 
	// 672, 793, 924, 1065, 1216, 1377, 1548, 1729, 
	// 1920, 2121, 2332, 2553, 2784, 3025, 3276, 3537, 
	// 3808, 4089, 4380, 4681, 4992, 5313, 5644, 
	// 5985, 6336, 6697, 7068 ... etc
  
	// Test k = 10
	task.dodecagonalNo(10);
}

Output

 1 12 33 64 105 156 217 288 369 460


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