3-3:编写一个java应用程序,使用for循环计算8+88+888... 的前10项之和。

public class Operation3_3{
  public static void main(String args[]){
    int i;
    long total=0;
    long f=8;
    for(i=1;i<=10;i++){
      total=total+f;
      f=10*f+f;
    }
    System.out.println(total);
  }
}

posted on 2013-03-19 22:30  Nephalem  阅读(2386)  评论(0编辑  收藏  举报

导航