码迷,mamicode.com
首页 > 其他好文 > 详细

HW5.1

时间:2016-08-19 23:53:12      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 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 }

 

HW5.1

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5789255.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!