Question: A hexagonal number is defined as 2n*(2n 1)/2 for n = 1, 2, , and so on. Therefore, the first few numbers are 1, 6,

A hexagonal number is defined as 2n*(2n 1)/2 for n = 1, 2, , and so on. Therefore, the first few numbers are 1, 6, 15, 28,

Write a method with the following header that returns a hexagonal number:

public static int getHexagonalNumber(int n)

Write a test program that calls this method to display the first 50 hexagonal numbers with 5 numbers on each line. Use printf to ensure the numbers are aligned to the right.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!