MapleStory Finger Point

๐Ÿƒ‍โ™‚๏ธBaekjoon/Java

[8393/JAVA] ํ•ฉ

HYEJU01 2021. 9. 4. 20:09
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int hap = 0 ;
for (int i = 1; i<= n; i++) {
hap += i;
}
System.out.printf("%d", hap);
}
}

hap ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•ด์„œ (์ดˆ๊ธฐํ™” ํ•„์ˆ˜)

๋ฐ›์€ n ๊ฐ’๋งŒํผ for๋ฌธ์œผ๋กœ ๋Œ๋ฆฌ๋ฉด์„œ ๋ˆ„์ ํ•ด์ฃผ๋ฉด ๋ !