Log is not feasible


Log is not feasible here as it brings precision error For ex log base 3 power 9 = 2.0000000000000004 which is not an integer


what is stopping you from typecasting the log value to an int? we are not concerned much about the decimal values as the question states that P has to be an integer. so whatever value the log function results, check if base^P == A