public class testDemo {
//100以内的所有数之和
public static void main(String[] args) {
int total = 0;
int end = 100;
//方法一:语句频度 T(n) = n + 1
for(int i = 0;i <= end; i++) {
total += i;
}
System.out.println("方法一:"+total);
//方法二:语句频度 T(n) = 1
total = (1+end)*end/2;
System.out.println("方法二:"+total);
}
}