isPowerOf method

bool isPowerOf(
  1. int base
)

Checks if this integer is a power of base.

Implementation

bool isPowerOf(int base) {
  if (base <= 1) return this == base;
  var n = this;
  while (n % base == 0) {
    n ~/= base;
  }
  return n == 1;
}