class Solution {
fun solution(price: Int, money: Int, count: Int): Long {
var loop = 0L
(1..count).forEach { loop += it }
val total = price * loop
return if(money - total < 0) {
total - money
} else {
0
}
}
fun solution1(price: Int, money: Int, count: Int): Long
= (1..count).sumOf { it * price.toLong() }.let { if (money > it) 0 else it - money }
}
Solution1 은 좀 변태같아서 가져와봄