This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
a(1) = 181, because 181 and 181 + 10 = 191 are two consecutive primes with the same last digit 1 and no smaller p has this property.
a(n) = my(p=11); while (!isprime(p) || ((nextprime(p+1)-p) != 10*n), p+=10); p; \\ Michel Marcus, Feb 20 2025
a(6) = 2229971 because this number is the first in a sequence of 6 consecutive primes all of the form 5n + 1.
NextPrime[ n_Integer ] := Module[ {k = n + 1}, While[ ! PrimeQ[ k ], k++ ]; Return[ k ] ]; PrevPrime[ n_Integer ] := Module[ {k = n - 1}, While[ ! PrimeQ[ k ], k-- ]; Return[ k ] ]; p = 0; Do[ a = Table[ -1, {n} ]; k = Max[ 1, p ]; While[ Union[ a ] != {1}, k = NextPrime[ k ]; a = Take[ AppendTo[ a, Mod[ k, 5 ] ], -n ] ]; p = NestList[ PrevPrime, k, n ]; Print[ p[ [ -2 ] ] ]; p = p[ [ -1 ] ], {n, 1, 10} ]
a(3) = 1627 as it is the start of the first occurrence of the three consecutive prime 1627, 1637 and 1657 ending in 7.
(p,q,r) = (1627,1637,1657), are three primes which are consecutive and end in the same digit. Hence, p=1627 is a member of this sequence.
f:=func; a:=[]; for p in PrimesUpTo(40000) do if f(p,1) or f(p,3) or f(p,7) or f(p,9) then Append(~a,p); end if; end for; a; // Marius A. Burtea, Oct 16 2019
q:= 3: r:= 5: count:= 0: R:= NULL: while count < 100 do p:= q; q:= r; r:= nextprime(r); if p-q mod 10 = 0 and q-r mod 10 = 0 then count:= count+1; R:= R, p; fi od: R; # Robert Israel, May 08 2020
First /@ Select[Partition[Prime@ Range@ 4105, 3, 1], Length@ Union@ Mod[#, 10] == 1 &] (* Giovanni Resta, Oct 16 2019 *)
isok(p) = {if (isprime(p), my(d = p % 10); my(q = nextprime(p+1), r = nextprime(q+1)); (d == (q % 10)) && (d == (r % 10)););} \\ Michel Marcus, Oct 17 2019
The triangle begins: 2; 139, 149; 1627, 1637, 1657; 18839, 18859, 18869, 18899; 123229, 123239, 123259, 123269, 123289; 776257, 776267, 776287, 776317, 776327, 776357;
a(6) = 11, because 11 initiates a sequence of exactly six consecutive palindromic primes: 11, 101, 131, 151, 181 and 191, each ending in the same digit 1.
# with A002385 e.g. from the b-file for that sequence R:= NULL: d:= 2: count:= 1: m:= 1; for i from 2 while m < 100 do dp:= A002385[i] mod 10; if d = dp then count:= count+1 else d:= dp; if count >= m then R:= R, seq(A002385[i-j],j=m..count); m:= count+1; fi; count:= 1; fi od: R; # Robert Israel, May 13 2025
from sympy import isprime from itertools import count, islice, product def palprimes(): # generator of palprimes yield from [2, 3, 5, 7, 11] for d in count(3, 2): for last in "1379": for p in product("0123456789", repeat=d//2-1): left = "".join(p) for mid in [[""], "0123456789"][d&1]: t = int(last + left + mid + left[::-1] + last) if isprime(t): yield t def agen(): # generator of terms adict, n, lastdigit, vlst = dict(), 1, 0, [2] for p in palprimes(): if p%10 == lastdigit: vlst.append(p) else: if len(vlst) >= n: for i in range(n, len(vlst)+1): if i not in adict: adict[i] = vlst[-i] while n in adict: yield adict[n]; n += 1 lastdigit, vlst = p%10, [p] print(list(islice(agen(), 40))) # Michael S. Branicky, Apr 13 2025
a(5) = 123229 because this number is the first in a sequence of 5 consecutive primes all of the form 5n + 4.
NextPrime[ n_Integer ] := Module[ {k = n + 1}, While[ ! PrimeQ[ k ], k++ ]; Return[ k ] ]; PrevPrime[ n_Integer ] := Module[ {k = n - 1}, While[ ! PrimeQ[ k ], k-- ]; Return[ k ] ]; p = 0; Do[ a = Table[ -1, {n} ]; k = Max[ 1, p ]; While[ Union[ a ] != {4}, k = NextPrime[ k ]; a = Take[ AppendTo[ a, Mod[ k, 5 ] ], -n ] ]; p = NestList[ PrevPrime, k, n ]; Print[ p[ [ -2 ] ] ]; p = p[ [ -1 ] ], {n, 1, 9} ]
a(3) = 43 because the 3 consecutive primes 43, 47, 53 all have squares ending in 9, while the primes 41 and 59 preceding 43 and following 53 have squares ending in 1.
N:= 16: # for a(1) .. a(N) V:= Vector(N): p:= 2: q:= 2: count:= 0: d:= 4: i:= 1: while count < N do p:= nextprime(p); if p^2 mod 10 <> d then if i <= N and V[i] = 0 then V[i]:= q; count:= count+1; fi; q:= p; i:= 1; d:= p^2 mod 10; else i:= i+1; fi od: convert(V,list);
upto(n) = { my(res = [], ld = 4, streak = 1); forprime(p = 3, n, nd = p^2 % 10; if(nd == ld, streak++ , if(streak > #res, res = concat(res, vector(streak - #res, i, oo)) ); if(res[streak] == oo, c = p; for(i = 1, streak, c = precprime(c-1); ); res[streak] = c; ); streak = 1; ); ld = nd ); res } \\ David A. Corneth, Oct 07 2023
Comments