login
Least number k > 1 such that a number composed of k consecutive ascending digits starting with n is prime.
0

%I #17 Nov 07 2024 15:22:20

%S 171,2,179,4,29,2,5,2,13

%N Least number k > 1 such that a number composed of k consecutive ascending digits starting with n is prime.

%C After the digit 9 comes 0 and it repeats.

%C If k could equal 1, the sequence becomes {171, 1, 1, 4, 1, 2, 1, 2, 13}.

%C It is interesting that when n is prime, a(n) is prime.

%e 78 is not prime. 789 is not prime. 7890 is not prime. 78901 is prime. Thus a(7) = 5 since 78901 is a 5-digit number.

%o (Python)

%o import sympy

%o from sympy import isprime

%o def a(n):

%o num = str(n)

%o for i in range(n+1, 10**3):

%o num += str(i%10)

%o if isprime(int(num)):

%o return len(num)

%o n=1

%o while n < 10:

%o print(a(n), end=', ')

%o n+=1

%o (PARI) a(n) = {s = Str(n); i = n+1; while (1, if (i==10, i = 0); s = concat(s, i); i++; if (isprime(eval(s)), return (length(s))););} \\ _Michel Marcus_, Jun 04 2014

%Y Cf. A120821.

%K nonn,base,full,fini

%O 1,1

%A _Derek Orr_, Jun 02 2014