import java.math.BigInteger
fun sumOfDigits(n: Int): Int {
val power = BigInteger.TWO.pow(n)
return power.toString().map { it.digitToInt() }.sum()
}
fun main() {
val testCases = listOf(15, 100, 1000)
for (n in testCases) {
println("Sum of digits of 2^$n is: ${sumOfDigits(n)}")
}
}
/*
run:
Sum of digits of 2^15 is: 26
Sum of digits of 2^100 is: 115
Sum of digits of 2^1000 is: 1366
*/