6.1(数学:五角数)一个五角数被定义为n(3n-1)/2,其中n = 1,2,…。所以,开始的几个数字就是1,5,12,22,…,编写具有下面所示方法头的方法,返回一个五角数:
public static int getPentagonalNumber(int n)
例如,getPentagonNumber(1)返回1,getPentagonNumber(2)返回5。编写一个测试程序显示前100个五角数,每行显示10个。使用%7d格式限定符来显示每个数字。
6.1(Math: pentagonal numbers) A pentagonal number is defined as n(3n-1)/2 for n = 1 , 2 , …, and so on. Therefore, the first few numbers are 1, 5, 12, 22, . . . . Write a method with the following header that returns a pentagonal number:
public static int getPentagona