I want to read two 50-digit numbers and print their sum, but I can't get input in Kotlin as BigInteger.
You can do it the same way as you would in Java:
val scanner = Scanner(System.`in`)
val first = scanner.nextBigInteger()
val second = scanner.nextBigInteger()
print(first + second)
OR you can use readLine()
from kotlin.io
:
val first = BigInteger(readLine())
val second = BigInteger(readLine())
print(first + second)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With