//小淇在敲代码
package p2;
import java.util.Scanner;
public class 从键盘上输入一个正整数n计算累加和并输出 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int n,i=1,sum=0;
Scanner buf=new Scanner(System.in);
do
{
System.out.println("输入正整数: ");
n=buf.nextInt();
}
while(n<=0);
while(i<=n)
sum+=i++;
System.out.println("1+2+...+"+n+"="+sum);
}
}