Group Abstract Group Abstract

Message Boards Message Boards

0
|
6K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Searching for 10-base number $n$ that follow two rules when written in base

Posted 4 years ago

Well, I am trying to write a clever code that looks for a 10-base number $n$ such that:

  1. The digit sum of $n$ in base $2$ must be equal to $k$;
  2. The GCD of the $n$ in base $2$ and the integer reverse of the number $n$ in base $2$ must be equal to $k$.

I already proved that the number $k$ must end with a $1,3,7$ or $9$. Otherwise, there is no solution possible for $n$. That sequence can be found using the following Mathematica-code:

In[1]=Map[(1/2*(5*# + Mod[3*# + 2, 4] - 4)) &, Range[25]]

Out[1]={1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49, 51, 53, 57, 59, 61}

Question: how can I find the minimal value of $n$ such that it obeys the rules stated above?


My work: the rules from above can be written as Mathematica-code as follows:

  1. k==Total[IntegerDigits[n,2]]
  2. k==GCD[FromDigits[IntegerDigits[n,2]],IntegerReverse[FromDigits[IntegerDigits[n,2]]]]

And I know the following solutions $\left(k,n\right)$:

$$\left(k,n\right)\in\left\{\left(1,1\right),\left(3,11\right),\left(9,767\right),\left(11,4543829\right),\left(17,1041919\right),\left(19,4120511\right)\right\}\tag1$$

But I am especially interested in $k=39$ and $k=41$.

I tried running the following code:

In[2]:=Clear["Global`*"];
DeleteCases[ParallelTable[
   First[ParallelTable[
       If[k == Total[IntegerDigits[n, 2]] && 
         k == GCD[FromDigits[IntegerDigits[n, 2]], 
           IntegerReverse[FromDigits[IntegerDigits[n, 2]]]], {k, n}, 
        Nothing], {n, 0, 10^7}] //. {} -> Nothing] // Quiet, {k, 
    Map[(1/2*(5*# + Mod[3*# + 2, 4] - 4)) &, Range[25]]}], 
  First[Nothing]] // Quiet

Out[2]={{1, 1}, {3, 11}, {9, 767}, {11, 4543829}, {17, 1041919}, {19, 
  4120511}}

But it gave limited solutions and not the one I am especially interested in.

POSTED BY: Jan Eerland
2 Replies
Posted 4 years ago

Using the nice code above and changing Do to ParallelDo, no solutions are found for 39 up to 10^10. Took ~2h on my M1 Max Macbook Pro running 8 kernels.

(* {6988.55, Null} *)

Seems to scale exponentially so testing up to 10^11 will take ~10 times as long.

POSTED BY: Rohit Namjoshi
Posted 4 years ago
POSTED BY: Updating Name
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard