1 //计算S=1+2+3+…+N+…,直到S>10000
2 public class getSum{
3 public static int sum(){
4 int s = 0;
5 int i = 0;
6 while(s<=10000){
7 i++;
8 s = s + i;
9 }
10 return (s-i);
11 }
12 public static void main(String[] args) {
13 System.out.println("sum():"+sum());
14 }
15 }
16
posted on 2006-01-20 09:50
★yesjoy★ 阅读(513)
评论(0) 编辑 收藏 所属分类:
算法总结