login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A341702 a(n) is the smallest k < n such that the decimal concatenation n||n-1||n-2||...||n-k is prime, or -1 if no such prime exists. 4

%I #20 Mar 02 2022 12:08:42

%S -1,-1,0,0,1,0,-1,0,-1,-1,1,0,-1,0,-1,-1,-1,0,-1,0,-1,-1,1,0,1,12,-1,

%T 4,-1,0,-1,0,-1,-1,1,-1,-1,0,-1,-1,-1,0,1,0,-1,-1,7,0,7,-1,-1,4,15,0,

%U -1,12,9,-1,1,0,13,0,-1,-1,-1,-1,-1,0,57,-1,1,0,-1,0

%N a(n) is the smallest k < n such that the decimal concatenation n||n-1||n-2||...||n-k is prime, or -1 if no such prime exists.

%C A variation of A341716. a(n) = n-1 for n = 82. Are there other n such that a(n) = n-1?

%C Similar argument as in A341716 shows that if n > 3 and a(n) >= 0, then n-a(n) is odd, a(n) !== 2 (mod 3) and 2n-a(n) !== 0 (mod 3).

%H Robert Israel, <a href="/A341702/b341702.txt">Table of n, a(n) for n = 0..2000</a>

%F a(n) = n-A341701(n).

%F a(p) = 0 if and only if p is prime.

%e a(10) = 1 since 109 is prime. a(22) = 1 since 2221 is prime.

%p tcat:= proc(x,y) x*10^(1+ilog10(y))+y end proc:

%p f:= proc(n) local x,k;

%p x:= n;

%p for k from 0 to n-1 do

%p if isprime(x) then return k fi;

%p x:= tcat(x,n-k-1)

%p od;

%p -1

%p end proc:

%p map(f, [$0..100]); # _Robert Israel_, Mar 02 2022

%o (Python)

%o from sympy import isprime

%o def A341702(n):

%o k, m = n, n-1

%o while not isprime(k) and m > 0:

%o k = int(str(k)+str(m))

%o m -= 1

%o return n-m-1 if isprime(k) else -1

%o (PARI) a(n) = my(k=0, s=Str(n)); while (!isprime(eval(s)), k++; n--; if (k>=n, return(-1)); s = concat(s, Str(n-k))); return(k); \\ _Michel Marcus_, Mar 02 2022

%Y Cf. A052088, A052089, A054211, A341701, A341715, A341716, A341717.

%K sign,base

%O 0,26

%A _Chai Wah Wu_, Feb 23 2021

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 3 00:14 EDT 2024. Contains 375621 sequences. (Running on oeis4.)