Candide Voltaire
2011-08-12 15:22:39 UTC
I need to check whether a number is a power of 3.
I tried the following:
isinteger(log(n)/log(3));
this doesn't work however (e.g. with n=27), probably because of the
floating point representation used internally in octave
Can anyone here suggest how to check whether n is a power of 3?
regards,
Candide
I tried the following:
isinteger(log(n)/log(3));
this doesn't work however (e.g. with n=27), probably because of the
floating point representation used internally in octave
Can anyone here suggest how to check whether n is a power of 3?
regards,
Candide