%I #35 Apr 29 2021 01:41:32
%S 12,0,35,77,611,1513,817,1219,2523,1829,2331,2337,3741,3243,5247,3953,
%T 1159,5561,5467,1971,6873,1079,4183,3589,9797,48101,3103,46107,33109,
%U 15113,120127,77131,67137,76139,45149,38151,104157,165163,100167,87173,101179,170181
%N a(2) = 0, and otherwise a(n) is the least multiple of prime(n+1) whose decimal representation ends with that of prime(n).
%C Inspired by the 134th problem of Project Euler (see link).
%C a(n) > 1 iff n != 2.
%C Some particular terms:
%C a(3) = 35 is the concatenation of prime(2) and prime(3),
%C a(4) = 77 is the palindrome prime(4) and prime(4),
%C a(13) = 3741 is the concatenation of prime(12) and prime(13),
%C a(25) = 9797 is the concatenation of prime(25) and prime(25).
%H Chai Wah Wu, <a href="/A333577/b333577.txt">Table of n, a(n) for n = 1..10000</a>
%H Project Euler, <a href="https://projecteuler.net/problem=134">Problem 134: Prime pair connection</a>.
%e For prime(2) = 3 and prime(3) = 5, there does not exist any integer that ends with 3 and is divisible by 5, hence a(2)=0 and it is the only term equal to 0.
%e For prime(5) = 11 and prime(6) = 13, 611 ends with 11 and 611=13*47 is divisible by 13, and no integer < 611 satisfies these two conditions, so a(5)= 611.
%t a[2] = 0; a[n_] := Module[{p = Prime[n], q, r}, q = NextPrime[p]; r = 10^Ceiling[Log10[p]]; While[!Divisible[p, q], p += r]; p]; Array[a, 100] (* _Amiram Eldar_, Mar 27 2020 *)
%o (PARI) a(n) = {if (n==2, return(0)); my(p = prime(n), q = prime(n+1), x = p, k = 0); until ((x % q) == 0, k++; x = eval(concat(Str(k), Str(p)));); x;} \\ _Michel Marcus_, Mar 28 2020
%o (PARI) a(n) = { if (n==2, return (0), my (p=prime(n), q=nextprime(p+1)); lift(chinese(Mod(p, 10^#digits(p)), Mod(0, q)))) } \\ _Rémy Sigrist_, Mar 29 2020
%o (Python)
%o from sympy import prime, nextprime, mod_inverse
%o def A333577(n):
%o if n == 2:
%o return 0
%o p = prime(n)
%o q, r = nextprime(p), 10**len(str(p))
%o return p*q*mod_inverse(q,r) % (q*r) # _Chai Wah Wu_, Mar 31 2020
%Y Cf. A000040, A333845 (variant).
%K nonn,base
%O 1,1
%A _Bernard Schott_, Mar 27 2020
%E More terms from _Amiram Eldar_, Mar 27 2020
%E Name improved by _Rémy Sigrist_, Mar 29 2020
|