Polygonal Number in Java
What does a Java Polygonal Number Mean?
In mathematics, a polygonal number refers to a number that is expressed through dots or pebbles arranged in a regular polygonal pattern. Alphas are the names given to the dots (units). These are specific kinds of two-dimensional figurate integers.
Explanation of Polygonal Number
The integers that represent dots arranged in a geometric arrangement are known as polygonal numbers. Each consecutive polygon uses an increasing number of dots, starting at a central point and radiating outward. The amount of dots that were utilized to create the figure increases predictably as it grows in size.
The vertices of both geometric patterns are equivalent to the polygonal number, which begins at 1. It discovers a polygonal quantity of patterns including triangles, squares, and pentagons. The next side of the figure causes the polygonal number to rise.
Polygonal numbers can be represented by discrete and regular geometrical shapes with consistently spaced points. If a standard polygon, standard polyhedron, or regular polytope can be formed from a given number, that number is said to be polygonal, polyhedral, or polytopic.
Java programming increases the number of polygons as much as is practical.
Number of the Polygonal Types
A 2-dimensional schematic is required for the shape to receive a polygonal number. There are a few simple Java diagrams for obtaining polygonal numbers. The figures that are most useful for locating polygonal numbers are the triangle and square. To obtain a polygonal number, we can use diagrams of the hexagon and pentagon.
- Triangular polygonal number
- Square Polygonal Number
- Pentagon Polygonal Number
- Hexagonal Polygonal Number
Triangular polygonal number
The polygonal number's triangle receives 1 for the first part and 3 for the second. The triangle's three sides add up to its increase.
Using the formula below, we can determine the triangular polygonal number
Polygonal = sides * (sides + 1)/2;
The triangular-shaped polygonal numbers are 1, 3, 6, 10, 15,...
Example program for a triangular polygonal number in java
public class Triangularpolygonal
{
static void findPterm(int sides)
{
System.out.println(sides * (sides + 1)/2);
}
public static void main(String[] args){
int times = 3;
System.out.print("The traingularPolyonal number: ");
findPterm(times);
}
}
Square Polygonal Number
The square receives 1 value for the polygonal number's first part and 4 values for its second term. By the square's four sides, it grows.
The square polygonal value can be calculated using the formula below.
Polygonal = sides * sides;</p>
The polygonal square numbers are 1, 4, 9, 16, and 25.
Example program for a square polygonal number in java
public class Squarepolygonal
{
static void findPterm(int sides)
{
System.out.println(sides * sides);
}
public static void main(String[] args)
{
int times = 2;
System.out.print(" The square polygonal number: ");
findPterm(times);
}
}
The output of the above program
The square polygonal number: 4
Pentagon Polygonal Number
The polygonal number's square receives 1 value for the initial expression and 5 integers for the second term. The pentagon's five sides add to the rise.
The formula below can be used to compute the pentagon polygonal number.
Polygonal = 3 * sides * sides - sides/2;
1, 5, 12, 22, and 35 are the pentagonal polygonal numbers!
Example program for a pentagonal polygonal number in java
public class Pentagonepolygonal
{
static void findPterm(int sides)
{
System.out.println(3 * sides * sides - sides/2);
}
public static void main(String[] args)
{
int times = 4;
System.out.print("The Pentagon polygonal number: ");
findPterm(times);
}
}
The output of the above program
The Pentagon polygonal number: 46
Hexagon Polygonal Number
The polygonal number's square receives 1 value for the first term and 6 values for the second term. By the hexagon's six sides, it rises.
We can use the following formula to determine the hexagon polygonal number.
polygonal=side* (2 * side - 1);
The integers that form hexagonal polygons are 1, 6, 15, 28, 45,...
Example program for a Hexagonal polygonal number in java
public class Hexagonepolygonal
{
static void findPterm(int sides)
{
System.out.println(sides * (2 * sides - 1));
}
public static void main(String[] args){
int times = 6;
System.out.print("The Hexagon polygonal number: ");
findPterm(times);
}
}
The output of the above program
The Hexagon polygonal number: 66
Polygonal Central Number
Java is used in the example below to find the sixth polygonal number. Java programming allows us to determine the central polygonal's n-th number.
Example program for a central polygonal number in java
public class Centralpolygonal {
static void findPterm(int sides)
{
System.out.println(sides * sides - sides + 1);
}
public static void main(String[] args){
int times = 6;
System.out.print("The central Polygonal number: ");
findPterm(times);
}
}
The output of the above program
The central Polygonal number: 31
The geometric polygon's polygonal number
The trigonometric number and the polygon number in the example are calculated using scanners. The scanner aids in selecting the necessary side as well as the time of both numbers. The formula for triangles, squares, and pentagons, and the necessary diagram are included in the example. A polygonal value of the figure is determined using the formula.
Conclusion for the java polygonal number
To obtain polygonal numbers in Java language, a formula is needed. The number aids in determining the vertices' order. The trigonometric figure's point and expanded diagram are obtained with the aid of the vertices.
Java's polygonal number aids in simplifying trigonometric calculations. Polygonal numbers are computed using Java programming according to requirements. The appropriate polygonal form and number can be calculated.