Im trying to make a program where you give to BigIntegers, finds their power and returns the last digit. But im having troubles passing the bigInteger into the pow method.Is there any way ?
Note: I dont want to change the bigInteger to an int
code:
import java.math.BigInteger;
fun main(args: Array<String>) {
println(lastDigit(BigInteger("1606938044258990275541962092341162602522202993782792835301376"),BigInteger("2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376")))
}
fun lastDigit(base: BigInteger, exponent: BigInteger): Int {
var allDigits : String = base.pow(exponent).toString()
return allDigits[allDigits.count()-1].toInt()
}
output:
Type mismatch: inferred type is BigInteger but Int was expected