Reputation: 150
I want to read two 50-digit numbers and print their sum, but I can't get input in Kotlin as BigInteger.
Upvotes: 4
Views: 991
Reputation: 11963
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)
Upvotes: 9