/*ë ì ì ì¬ì´ì í© ë¬¸ì ì¤ëª ë ì ì a, bê° ì£¼ì´ì¡ì ë aì b ì¬ì´ì ìí 모ë ì ìì í©ì 리í´íë í¨ì, solutionì ìì±íì¸ì. ì를 ë¤ì´ a = 3, b = 5ì¸ ê²½ì°, 3 + 4 + 5 = 12ì´ë¯ë¡ 12를 리í´í©ëë¤. ì í ì¡°ê±´ aì bê° ê°ì ê²½ì°ë ë ì¤ ì무 ìë 리í´íì¸ì. aì bë -10,000,000 ì´ì 10,000,000 ì´íì¸ ì ìì ëë¤. aì bì ëìê´ê³ë ì í´ì ¸ìì§ ììµëë¤. ì ì¶ë ¥ ì a b return 3 5 12 3 3 3 5 3 12*/ package level1; import java.util.Scanner; public class TwoInputSum { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); TwoInputSum tis = new TwoInputSum(); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(tis.solution(a,b)); sc.close(); } public long solution(int a, int b) { int temp = 0; if(a > b) { temp = a; a = b; b = temp; } long answer = 0; for(int i = a; i <= b; i++) { answer += i; } return answer; } }