title: How can I write this code so that I do not have to round the logarithm?
body: <p>I was doing a programming challenge question where you need to found out if a given number (n) is equal to 3 raised to some exponent(x)</p>
  <p>9 is True since 3^x -&gt; 3^3 = 9</p>
  <p>10 is False since no x for 3^x is equal to 10</p>
  <p>my problem occurred when 243 was entered into my code, which returned a result of 4.999 repeating.</p>
  <p>my solution was to simply add a round function, in which I arbitrarily decided on 5 decimal places, this solved the problem.</p>
  <p>now another problem occurred when the input was 531440, this returns an x value of 11.999998287222695 which, according to the challenge, was false, but with my code returned a true since I rounded to the fifth decimal place. I then changed my round to 10 decimal places and this fixed the code.</p>
  <p>I was wondering if there was a way to implement my solution without having to round, as I'm sure if I plugged in enough numbers eventually another one would need to round past &gt;10 decimal places and cause my code to fail. Please see the code below.</p>
  <pre><code>import math as math
  
  def isPowerOfThree(n):
      print(math.log(n,3))                                     #this line prints the unrounded log result
      print(round((math.log(n,3)),10))                         #this line prints the rounded result
      return n&gt;0 and round((math.log(n,3)),10).is_integer()
  
  n = 243
  print(isPowerOfThree(n))
  </code></pre>