输入n,求1~n累加 最开始可能会使用for循环来计算,现在直接使用等差数据计算和公式:s=(a0+n)*n/2 long sum(int n) { long ret=0; ret = (1+n)* n /2; return ret; }