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.

Original entry on oeis.org

11, 101, 101, 20101, 210101, 4010101, 61010101, 1601010101, 8101010101, 260101010101, 3110101010101, 11010101010101, 11010101010101, 1201010101010101, 6101010101010101, 180101010101010101, 1710101010101010101, 5010101010101010101, 41010101010101010101
Offset: 1

Views

Author

James S. DeArmon, Dec 27 2024

Keywords

Comments

Leading zeros are not allowed, so that prime p = 101 does not end 0101 and is not a candidate for a(4).
For n>=5, the ending is not itself prime, so that the prefix must be a positive integer.
Some terms are repeated, e.g., 11010101010101 ends with "010101010101" and also ends with the next element in alternating series "1010101010101".

Examples

			For n=4, the required ending is the 4 digits 0101, and the smallest prime ending that way is a(4) = 20101.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local t0,t,k;
      t0:= add(10^k,k=0..n-1,2);
      if n::even then t0:=t0 + 10^n fi;
      for t from t0 by 10^n do if isprime(t) then return t fi od
    end proc:
    map(f, [$1..20]); # Robert Israel, Feb 26 2025
  • Mathematica
    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 *)
  • Python
    from sympy import isprime
    from itertools import count
    def a(n):
        ending = int(("01"*n)[-n:])
        if n&1 and isprime(ending): return ending
        return next(i for i in count(10**n+ending, 10**n) if isprime(i))
    print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Jan 26 2025