This is my algorithm so far:
It prints out the highest pth for 17, 625, 1024 and 10000, which is 1, 4, 10, and 4, instantly but i'm trying to speed it up finding it for 1073741824. I know the math.pow() is slow and I was wondering if anyone had any ideas on how to generally speed up the algorithm.public static int getPth(int x) { int largestP = 1; for (int p = 1; p < x; p++) { for (int b = 1; b < x; b++) { double ans = Math.pow(b, p); if (ans > x) { break; }else if(ans == x) { largestP = p; } } } return largestP; }