๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

[JAVA] 1 ๋ถ€ํ„ฐ 100๊นŒ์ง€ ์ˆซ์ž๋ฅผ ํ•ฉํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜

by yunamom 2022. 2. 26.
๋ฐ˜์‘ํ˜•
Class Solution {
	public int solution(int num){
    	int sum = num*(num+1)/2;
    
    	return sum; 
    }
}
public class ์ˆซ์ž๋”ํ•˜๊ธฐ {
	public static void main(String[] args) {
		
		Solution test = new Solution();
		System.out.println(test.solution(100));
	}
}

// ๊ฒฐ๊ณผ : 5050

for ๋ฌธ์„ ์ด์šฉํ•˜๋Š”๊ฒƒ๋ณด๋‹ค ํ›จ์”ฌ ํšจ์œจ์ ์ด๋‹ค :)

300x250

์ฝ”๋“œ