Pandigital exponent solution?

83 Views Asked by At

I don't have Reviewing C++ By Alex Maurea book. But someone in facebook post a question from this book which is following

You can see the puzzle at page 542 problem 29.

Now I think the answer should be log2123456798. Am I right or I am tackling the question wrong way?

1

There are 1 best solutions below

3
On

You tackled in a wrong way. You must check the powers of 2 and find the smallest one, such that the last 9 digits are pairwise different and greater than 0.

By the way, the solution is

k=955

with ending digits

247315968

I found it with the following PARI-program

? k=1;gef=0;while(gef==0,k=k+1;n=Mod(2^k,10^9);u=component(n,2);x=vector(9);null =0;while(u>0,j=u-truncate(u/10)$*$10;if(j>0,x[j]=x[j]+1);if(j==0,null=1);u=truncat e(u/10));if((null==0)$*$(vecmin(x)>0),gef=1));print(k)