Post

백준 - 2231 분해합

백준 - 2231 분해합

문제

2231 분해합

screencaptures

답

kotlin code

1
2
3
4
5
6
7
8
9
10
11
12
fun main() {
    val input = readln().toInt()

    for(n in input/2 until input) {
        val digitSum = "$n".sumOf { it - '0' }
        if(input == (n + digitSum)) {
            println(n)
            return
        }
    }
    println(0)
}
This post is licensed under CC BY 4.0 by the author.