Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java programming language We saw in class a sequence called the Triangular Numbers, that begins 1,3,6,10,15, The sequence gets its name because they are the
java programming language
We saw in class a sequence called the Triangular Numbers, that begins 1,3,6,10,15, The sequence gets its name because they are the numbers of dots in equilateral triangles of side lengths 1,2,3,4,5,. as shown below: We can find similar sequences for polygons of any number of sides. For example, squares, pentagons, and hexagons yield the three sequences illustrated below: The nod dots in each diagram illustrate which dots are added to create the next shape, suggesting a pattern in each case. In fact, there is a single unifying pattern for all such polygonal scquences. For a polygon with numSides sides, the nth term in its sequence is given by the formula For example, the fourth (i.e n=4 ) term for the Triangular Numbers (i.e. numSides =3 ) is 2(32)(4)2(34)(4)=10 which agroes with the illustration for the Triangular Numbers given above. Write a static method printPolygonals that takes two integers numsides and 1 imit as inputs, and it uses the formula above to print all the terms up to (but not including) a value of limit from the polygonal sequence for polygons with numsides sides. Each printed number should be separated by a comma and a space on the same line. For example, Lab2P2.printPolygonals (5,50) should print the numbers 1,5,12,22,35, and Lab2P2,printPolygonals (9,100) should print the numbers 1,9,24,46,75 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started