If a = 15 and 152 is represented as a2 , and 215 is represented as 2a , then it is necessary to find the number x so that
8x = 8*x8
I tried this naive Python code
>>> i = 0 >>> while(i<=100000000000000000): ... if(int("8"+str(i))==8*int(str(i)+"8")): ... break ... i = i+1 ... print i
but it takes a huge amount of time to get the right result.
How to optimize the code?
python math
Robin day
source share