C language sequence summation

Problem description
 Find the value of 1+2+3+...+n.
The input format
 input consists of an integer n.
The output format
 outputs a line, including an integer, representing the value of 1+2+3+...+n.
Sample input
 4
Sample output
 10
Sample input
 100

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n;
	long long m;
	scanf("%d",&n);
	m=n;
	printf("%I64d",(m+1)*m/2);
	system("pause");
	return 0;
}

Guess you like

Origin blog.csdn.net/YSL_Lsy_/article/details/105313520
Recommended