n
is less than 1. If it is, return false
because powers of three are positive numbers.3^19
which is the largest power of three that fits in an integer.3^19
modulo n
is 0. If it is, n
is a divisor of 3^19
and thus a power of three.true
if the modulo is 0, otherwise return false
.