알고리즘/JAVA
[JAVA] 백준 알고리즘 8393 : 합
초보개발자꽁쥐
2018. 7. 30. 13:31
반응형
1부터 N까지 합을 구합니다
문제 |
소스 |
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int input = sc.nextInt(); int result = 0; while (input > 0) { result += input; input--; } System.out.print(result); } }
출처 |
반응형