2. A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, ..., etc.. Therefo the first few numbers are 1, 5, 12, 22, . . . . Write a method with the following header that returns a pentagonal number: public static int getPentagonalNumber(int n)
2. A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, ..., etc.. Therefo the first few numbers are 1, 5, 12, 22, . . . . Write a method with the following header that returns a pentagonal number: public static int getPentagonalNumber(int n)
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 7E
Related questions
Question
![2. A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, ..., etc.. Therefore,
the first few numbers are 1, 5, 12, 22, ... . Write a method with the following
header that returns a pentagonal number:
%3D
public static int getPentagonalNumber(int n)
For example, getPentagonalNumber(1) returns 1
and getPentagonalNumber(2) returns 5. Write a test program that uses this method
to display the first 100 pentagonal numbers with 10 numbers on each line.
Numbers are separated by exactly one space.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0b54cbd5-e9a4-4e27-8866-ff5cac671566%2Fd533718d-6103-4f5e-8432-a8303c0fa73f%2F6n5se0j_processed.png&w=3840&q=75)
Transcribed Image Text:2. A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, ..., etc.. Therefore,
the first few numbers are 1, 5, 12, 22, ... . Write a method with the following
header that returns a pentagonal number:
%3D
public static int getPentagonalNumber(int n)
For example, getPentagonalNumber(1) returns 1
and getPentagonalNumber(2) returns 5. Write a test program that uses this method
to display the first 100 pentagonal numbers with 10 numbers on each line.
Numbers are separated by exactly one space.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr