You’d do better to repeatedly divide y into x. The first time you get a non-zero remainder you know x is not an integer power of y.
while (x%y == 0) x = x / y
return x == 1
This deals with your odd/even point on the first iteration.
More Related Contents:
- Custom Weighted Scale [closed]
- How to find nth prime with complexity o(1)
- Calculate distance between two latitude-longitude points? (Haversine formula)
- How to determine if a point is in a 2D triangle? [closed]
- How do I calculate a point on a circle’s circumference?
- Algorithm to find Largest prime factor of a number
- Is log(n!) = Θ(n·log(n))?
- How to calculate an angle from three points? [closed]
- Select k random elements from a list whose elements have weights
- How to make rounded percentages add up to 100%
- Writing your own square root function
- Finding out nth fibonacci number for very large ‘n’
- What is the fastest integer factorization algorithm?
- Why does this simple shuffle algorithm produce biased results?
- Computing set intersection in linear time?
- Unsupervised clustering with unknown number of clusters
- Calculate largest inscribed rectangle in a rotated rectangle
- Circle-circle intersection points
- How to find the smallest number with just 0 and 1 which is divided by a given number?
- How to calculate the index (lexicographical order) when the combination is given
- How do I find a factorial? [closed]
- Calculating the position of points in a circle
- Strategies for simplifying math expressions
- How to express tetration function, for complex numbers
- What is the method for converting radians to degrees?
- Given Prime Number N, Compute the Next Prime?
- How to check if an integer is a power of 3?
- Find out which combinations of numbers in a set add up to a given total
- Optimized low-accuracy approximation to `rootn(x, n)`
- Creating combinations that have no more one intersecting element