%I #58 Jan 11 2022 21:40:11
%S 1,11,4399137296449,767,4543829,302306413101798081695809,1041919,
%T 4120511,119471087,92239871,461373439,3221191679,25098711039,
%U 5864072675327,2642508222647189060948556167549513,20016007615544303,208836273045503,70085007900671,985162418485119
%N For numbers x_n coprime to 10 there exist infinitely many binary numbers b such that gcd(b,rev(b)) = x_n and digitsum(b) = x_n. a(n) is the smallest b converted to decimal that satisfies this constraint.
%C Only for numbers x_n coprime to 10 (A045572, i.e., numbers ending with 1,3,7 or 9) do there exist binary numbers b such that gcd(b, rev(b)) = x_n and digitsum(b) = x_n. For the numbers 7 and 13 and the porous numbers 11, 37 and 101 (A337832), the terms in their binary form have more zeros than ones, which are called long solutions. In these cases, let e = mult_order(10, n), then b = 10^(e*n) + Sum_{i=0..n-2} 10^(e*i). For example, the multiplicative order of 10 mod 11 is 2 and 10001010101010101010101 is the solution. However, in the case of the porous number 121, this formula does not work because both b and rev(b) are divisible by 1111111111111111111111 which also has a multiplicative order of 10 = 22 like 121 and therefore two extra zeros need to be inserted.
%C For most numbers short solutions exist. Which numbers have a short solution and which have a long solution is still unclear.
%C For clarification: in gcd(1011,1101)=3 the two numbers 1011 and 1101 are base-10 numbers, but then 1011 is interpreted as a base-2 number and translated back to base 10 to get a(2)=11 (=8+2+1).
%H Ruediger Jehn, <a href="/A348480/b348480.txt">Table of n, a(n) for n = 1..54</a>
%H Rüdiger Jehn, <a href="https://youtu.be/w2sC1FSpmPA">A new 200 Euro math puzzle</a>, Youtube video, Sep 17 2021.
%H Rüdiger Jehn, <a href="https://arxiv.org/abs/2201.00710">Long Solutions of Sequence A348480 of the On-Line Encyclopedia of Integer Sequences</a>, arXiv:2201.00710 [math.GM], 2022.
%e x_2 = 3. a(2)=11 which in binary is 1011. gcd(1011,1101)=3 and there is no smaller binary number that satisfies this constraint.
%e x_4 = 9. a(4)=767 which in binary is 1011111111. gcd(1011111111,1111111101)=9 and there is no smaller binary number that satisfies this constraint.
%o (PARI) xx(n) = 2*n - 1 + (n+1)\4 * 2; \\ A045572
%o gcdr(n) = my(b=binary(n)); gcd(fromdigits(Vecrev(b), 10), fromdigits(b, 10));
%o a(n) = my(b=1, x=xx(n)); while ((hammingweight(b) != x) || (gcdr(b) != x), b++); b; \\ _Michel Marcus_, Dec 01 2021
%o (Python)
%o from sympy.utilities.iterables import multiset_permutations
%o from itertools import count
%o from math import gcd
%o def A348480(n):
%o if n == 1: return 1
%o xn = 2*(n+(n+1)//4) - 1
%o for l in count(xn-1):
%o for d in multiset_permutations(['0']*(l-xn+1)+['1']*(xn-1)):
%o s = '1'+''.join(d)
%o if gcd(int(s),int(s[::-1])) == xn:
%o return int(s,2) # _Chai Wah Wu_, Jan 08 2022
%Y Cf. A045572, A333666, A337832, A350385.
%K nonn,base
%O 1,2
%A _Ruediger Jehn_, Oct 20 2021
%E a(13) from _Giorgos Kalogeropoulos_, Oct 22 2021
%E a(14) from _Pontus von Brömssen_, Oct 23 2021
%E a(15) from _Ruediger Jehn_, Dec 01 2021
%E a(16) - a(29) from _Ruediger Jehn_, Dec 17 2021
%E a(30) - a(54) from _Ruediger Jehn_, Jan 11 2022