cp's OEIS Frontend

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.

A377370 Smallest prime ending in n alternating decimal digits 0 and 1.

This page as a plain text file.
%I A377370 #41 Feb 27 2025 07:58:16
%S A377370 11,101,101,20101,210101,4010101,61010101,1601010101,8101010101,
%T A377370 260101010101,3110101010101,11010101010101,11010101010101,
%U A377370 1201010101010101,6101010101010101,180101010101010101,1710101010101010101,5010101010101010101,41010101010101010101
%N A377370 Smallest prime ending in n alternating decimal digits 0 and 1.
%C A377370 Leading zeros are not allowed, so that prime p = 101 does not end 0101 and is not a candidate for a(4).
%C A377370 For n>=5, the ending is not itself prime, so that the prefix must be a positive integer.
%C A377370 Some terms are repeated, e.g., 11010101010101 ends with "010101010101" and also ends with the next element in alternating series "1010101010101".
%H A377370 Robert Israel, <a href="/A377370/b377370.txt">Table of n, a(n) for n = 1..992</a>
%e A377370 For n=4, the required ending is the 4 digits 0101, and the smallest prime ending that way is a(4) = 20101.
%p A377370 f:= proc(n) local t0,t,k;
%p A377370   t0:= add(10^k,k=0..n-1,2);
%p A377370   if n::even then t0:=t0 + 10^n fi;
%p A377370   for t from t0 by 10^n do if isprime(t) then return t fi od
%p A377370 end proc:
%p A377370 map(f, [$1..20]); # _Robert Israel_, Feb 26 2025
%t A377370 s={};d={};Do[If[OddQ[n],PrependTo[d,1],PrependTo[d,0]];If[PrimeQ[FromDigits[d]&&OddQ[n]],p=FromDigits[d],i=0;p=FromDigits[Prepend[d,i]];Until[PrimeQ[p],i++;p=FromDigits[Prepend[d,i]]]];AppendTo[s,p],{n,19}];s (* _James C. McMahon_, Feb 08 2025 *)
%o A377370 (Python)
%o A377370 from sympy import isprime
%o A377370 from itertools import count
%o A377370 def a(n):
%o A377370     ending = int(("01"*n)[-n:])
%o A377370     if n&1 and isprime(ending): return ending
%o A377370     return next(i for i in count(10**n+ending, 10**n) if isprime(i))
%o A377370 print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Jan 26 2025
%Y A377370 Cf. A036952, A065720.
%K A377370 nonn,base
%O A377370 1,1
%A A377370 _James S. DeArmon_, Dec 27 2024