# Centered square numbers

Here given code implementation process.

``````// C Program for
// Centered square numbers
#include <stdio.h>

void centeredSquareNo(int k)
{
// Print all initial k centered square number
for (int n = 1; n <= k; ++n)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
int result = ((n *n) + ((n - 1) *(n - 1)));

// Display calculated result
printf("  %d", result);
}
}
int main()
{
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
centeredSquareNo(10);
return 0;
}``````

#### Output

``  1  5  13  25  41  61  85  113  145  181``
``````// Java program for
// Centered square numbers
public class SquareNumber
{
public void centeredSquareNo(int k)
{
// Print all initial k centered square number
for (int n = 1; n <= k; ++n)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
int result = ((n * n) + ((n - 1) * (n - 1)));

// Display calculated result
System.out.print(" " + result);
}
}
public static void main(String[] args)
{
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
}
}``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``
``````// Include header file
#include <iostream>
using namespace std;
// C++ program for
// Centered square numbers

class SquareNumber
{
public: void centeredSquareNo(int k)
{
// Print all initial k centered square number
for (int n = 1; n <= k; ++n)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
int result = ((n *n) + ((n - 1) *(n - 1)));

// Display calculated result
cout << " " << result;
}
}
};
int main()
{
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
return 0;
}``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``
``````// Include namespace system
using System;
// Csharp program for
// Centered square numbers
public class SquareNumber
{
public void centeredSquareNo(int k)
{
// Print all initial k centered square number
for (int n = 1; n <= k; ++n)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
int result = ((n * n) + ((n - 1) * (n - 1)));

// Display calculated result
Console.Write(" " + result);
}
}
public static void Main(String[] args)
{
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
}
}``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``
``````package main
import "fmt"
// Go program for
// Centered square numbers

func centeredSquareNo(k int) {
// Print all initial k centered square number
for n := 1 ; n <= k ; n++ {
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
var result int = ((n * n) + ((n - 1) * (n - 1)))

// Display calculated result
fmt.Print(" ", result)
}
}
func main() {

// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
centeredSquareNo(10)
}``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``
``````<?php
// Php program for
// Centered square numbers
class SquareNumber
{
public	function centeredSquareNo(\$k)
{
// Print all initial k centered square number
for (\$n = 1; \$n <= \$k; ++\$n)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
\$result = ((\$n * \$n) + ((\$n - 1) * (\$n - 1)));

// Display calculated result
echo(" ".\$result);
}
}
}

function main()
{
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
}
main();``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``
``````// Node JS program for
// Centered square numbers
class SquareNumber
{
centeredSquareNo(k)
{
// Print all initial k centered square number
for (var n = 1; n <= k; ++n)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
var result = ((n * n) + ((n - 1) * (n - 1)));

// Display calculated result
process.stdout.write(" " + result);
}
}
}

function main()
{
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
}
main();``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``
``````#  Python 3 program for
#  Centered square numbers
class SquareNumber :
def centeredSquareNo(self, k) :
n = 1
#  Print all initial k centered square number
while (n <= k) :
#  Centered square
#  formula = (n)² + (n-1)²

#  CalculatedCentered square numbers
result = ((n * n) + ((n - 1) * (n - 1)))

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

def main() :
#  Centered square numbers
#  --------------------------------------
#  1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
#  265, 313, 365, 421, 481, 545, 613, 685, 761,
#  841, 925, 1013, 1105, 1201, 1301, 1405,
#  1513, 1625, 1741, 1861, 1985, 2113, 2245,
#  2381, 2521, 2665, 2813, 2965, 3121, 3281,
#  3445, 3613, 3785, 3961, 4141 .. etc

#  Test
#  k = 10

if __name__ == "__main__": main()``````

#### Output

``  1  5  13  25  41  61  85  113  145  181``
``````#  Ruby program for
#  Centered square numbers
class SquareNumber
def centeredSquareNo(k)
n = 1
#  Print all initial k centered square number
while (n <= k)
#  Centered square
#  formula = (n)² + (n-1)²

#  CalculatedCentered square numbers
result = ((n * n) + ((n - 1) * (n - 1)))

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

end

end

def main()
#  Centered square numbers
#  --------------------------------------
#  1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
#  265, 313, 365, 421, 481, 545, 613, 685, 761,
#  841, 925, 1013, 1105, 1201, 1301, 1405,
#  1513, 1625, 1741, 1861, 1985, 2113, 2245,
#  2381, 2521, 2665, 2813, 2965, 3121, 3281,
#  3445, 3613, 3785, 3961, 4141 .. etc

#  Test
#  k = 10
end

main()``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``
``````// Scala program for
// Centered square numbers
class SquareNumber()
{
def centeredSquareNo(k: Int): Unit = {
var n: Int = 1;
// Print all initial k centered square number
while (n <= k)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
var result: Int = ((n * n) + ((n - 1) * (n - 1)));

// Display calculated result
print(" " + result);
n += 1;
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var task: SquareNumber = new SquareNumber();
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc
// Test
// k = 10
}
}``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``
``````// Swift 4 program for
// Centered square numbers
class SquareNumber
{
func centeredSquareNo(_ k: Int)
{
var n: Int = 1;
// Print all initial k centered square number
while (n <= k)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
let result: Int = ((n * n) + ((n - 1) * (n - 1)));

// Display calculated result
print(" ", result, terminator: "");
n += 1;
}
}
}
func main()
{
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
}
main();``````

#### Output

``  1  5  13  25  41  61  85  113  145  181``
``````// Kotlin program for
// Centered square numbers
class SquareNumber
{
fun centeredSquareNo(k: Int): Unit
{
var n: Int = 1;
// Print all initial k centered square number
while (n <= k)
{
// Centered square
// formula = (n)² + (n-1)²

// CalculatedCentered square numbers
val result: Int = ((n * n) + ((n - 1) * (n - 1)));

// Display calculated result
print(" " + result);
n += 1;
}
}
}
fun main(args: Array < String > ): Unit
{
// Centered square numbers
// --------------------------------------
// 1, 5, 13, 25, 41, 61, 85, 113, 145, 181, 221,
// 265, 313, 365, 421, 481, 545, 613, 685, 761,
// 841, 925, 1013, 1105, 1201, 1301, 1405,
// 1513, 1625, 1741, 1861, 1985, 2113, 2245,
// 2381, 2521, 2665, 2813, 2965, 3121, 3281,
// 3445, 3613, 3785, 3961, 4141 .. etc

// Test
// k = 10
}``````

#### Output

`` 1 5 13 25 41 61 85 113 145 181``

## Comment

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.