8393번: 합
n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오.
www.acmicpc.net
Comment : 1~n까지의 합을 구하는 문제이다. 고딩 떄 합공식을 배웠으면 매우 쉽게 풀 수 있는 문제.
#include <stdio.h>
int main()
{
int n,s;
scanf("%d" , &n);
if( (n<1) || (n>10000) )
printf("ERROR");
s = n*(n+1)/2;
printf("%d" , s);
}