SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
import java.util.Scanner;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
int score = 0;
for (int i=0; i<=T; i++){
score = score + i;
}
System.out.print(score);
}
}
N(N+1)/2 가 훨씬 짧고 쉽다
'SWEA' 카테고리의 다른 글
[SWEA] 간단한 N 의 약수 (0) | 2024.09.19 |
---|---|
[SWEA] 아주 간단한 계산기 (0) | 2024.09.19 |
[SWEA] 대각선 출력하기 (0) | 2024.09.19 |
[SWEA] 몫과 나머지 출력하기 (0) | 2024.09.19 |
[SWEA] 서랍의 비밀번호 (1) | 2024.09.16 |