Ishtiaq11's blog

By Ishtiaq11, history, 5 years ago, I have two integer b,n. I need to check if the number n is integer power of number b. For example: 100 is an integer power of 10. As 10^2 = 100. But 110 is not an integer power of 10. How to determine this in coding?  Comments (10)
 » Try to do like this:Find log2 of n. Then divide it by log2 of b.If the result is integer, then n is power of b.
•  » » Thank you.I know a way how to check if a number is an integer or not. if int(res) == ceil(res): integer else: not integer if there is another way, please suggest me.
•  » » » b divides a if ( (a/b)*b == a)
•  » » » » Its more efficient. Thanks for helping.
 » 5 years ago, # | ← Rev. 2 →   k=b while(k
•  » » Thank you. But I can't understand the condition for avoiding overflow. Can you please explain why this condition is needed? If I comment out this line, what error will occur.
•  » » » n = 2*1e18 and b = 1e9
•  » » » » Thanks.
•  » » » HelloCheck this problem : http://codeforces.com/contest/614/problem/A ,and you will see why this condition is important, and how can overflow occur.
•  » » » » Thanks