(프로그래머스) 멀쩡한 사각형

유지원·2022년 6월 3일
0

프로그래머스

목록 보기
57/66

문제 링크

https://programmers.co.kr/learn/courses/30/lessons/62048?language=javascript


Javascript

function solution(w,h) {
	const slope = h / w;
	let result = 0;

	for (let i = 1; i <= w; i++) {
		result += Math.ceil(slope * i);
	}

	return ((h * w) - result) * 2;
}
profile
👋 https://github.com/ujw0712

0개의 댓글