240426
1
ํ์ด
function solution(price, money, count) {
let sumCount = 0
let sumArray = []
for(let i = 1; i <= count; i++) {
sumCount += price
sumArray.push(sumCount)
}
const sum = sumArray.reduce((acc, cur)=> {
return acc + cur
}, 0)
return money > sum ? 0 : sum - money
}๐ ๋ค๋ฅธ ์ฌ๋ ํ์ด
Last updated