1 public class Solution 2 { 3 public static void main(String[] args) 4 { 5 int count = 0; 6 7 for(int i = 1; i <= 100; i++) 8 { 9 System.out.print(getPentagonalNumber(i) + " "); 10 count++; 11 12 if(count == 10) 13 { 14 System.out.println(); 15 count = 0; 16 } 17 } 18 } 19 20 public static int getPentagonalNumber(int n) 21 { return n * (3 * n - 2) / 2; } 22 }
时间: 2024-10-10 04:12:11