Family Day update

This commit is contained in:
Ingy döt Net 2020-02-17 23:21:07 -08:00
parent aac6731f2c
commit 9ad63ea473
2442 changed files with 39761 additions and 8255 deletions

View file

@ -3,19 +3,19 @@
infix fun Int.ipow(exp: Int): Int =
when {
this == 1 -> 1
this == -1 -> if (exp % 2 == 0) 1 else -1
this == -1 -> if (exp and 1 == 0) 1 else -1
exp < 0 -> throw IllegalArgumentException("invalid exponent")
exp == 0 -> 1
else -> {
var ans = 1
var base = this
var e = exp
while (e > 0) {
while (e > 1) {
if (e and 1 == 1) ans *= base
e = e shr 1
base *= base
}
ans
ans * base
}
}