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.

User: James S. DeArmon

James S. DeArmon's wiki page.

James S. DeArmon has authored 35 sequences. Here are the ten most recent ones:

A387199 Numbers which are not themselves palindromes, but a single swap of two digits creates a palindrome.

Original entry on oeis.org

110, 112, 113, 114, 115, 116, 117, 118, 119, 122, 133, 144, 155, 166, 177, 188, 199, 211, 220, 221, 223, 224, 225, 226, 227, 228, 229, 233, 244, 255, 266, 277, 288, 299, 311, 322, 330, 331, 332, 334, 335, 336, 337, 338, 339, 344, 355, 366, 377, 388, 399, 411, 422
Offset: 1

Author

James S. DeArmon, Aug 21 2025

Keywords

Comments

Might be called "single-transposition palindromes".
Leading zeros are not allowed in either the initial number or the resultant palindrome.

Examples

			110 is a term since a swap of the second and third digits yields the palindrome 101.
		

Crossrefs

Cf. A002113.

Programs

  • Python
    def pal(s): return s == s[::-1]
    def swaps(s): yield from (t for i in range(len(s)-1) for j in range(i+1, len(s)) if (t:=s[:i]+s[j]+s[i+1:j]+s[i]+s[j+1:])[0]!='0')
    def ok(n): return not pal(s:=str(n)) and any(pal(t) for t in swaps(s))
    print([k for k in range(425) if ok(k)]) # Michael S. Branicky, Aug 22 2025

Extensions

More terms from Michael S. Branicky, Aug 22 2025

A383502 Position of the first instance of prime(n), in base 3, in the ternary representation of Pi after the ternary point.

Original entry on oeis.org

2, 4, 6, 2, 12, 20, 6, 10, 27, 16, 85, 3, 35, 78, 95, 6, 38, 96, 19, 27, 9, 66, 157, 171, 81, 191, 12, 127, 52, 3, 36, 275, 88, 589, 283, 40, 290, 952, 47, 10, 1213, 750, 572, 84, 126, 2, 282, 162, 125, 480, 26, 66, 185, 157, 1490, 1310, 832, 1321, 352
Offset: 1

Author

James S. DeArmon, Apr 28 2025

Keywords

Comments

Positions are numbered starting from 1 for the first ternary digit after the ternary point in Pi.

Examples

			The ternary digits of Pi and their numbering, after the ternary point, begin
          1 2 3 4 5 6 7 8 9 ...
   0 1  . 0 2 1 1 0 1 2 2 2 2 0 1 0 2 ...
                    \---/
prime(7) is 17, or 122_3, which first appears at position 6.
		

Crossrefs

Programs

  • Python
    import gmpy2
    from sympy import isprime
    def to_base3(n):
        if n == 0: return '0'
        d = []
        while n: d.append(str(n % 3)); n //= 3
        return ''.join(reversed(d))
    gmpy2.get_context().precision = 1200000
    pi_ternary = gmpy2.digits(gmpy2.const_pi(),3)[0][4:]  # skip "10."
    out = []
    for p in range(2, 280):
        if isprime(p):
            pos = pi_ternary.find(to_base3(p)) + 1
            out.append(pos)
    print(out)

A381041 Smallest prime p such that 3^n + p + 1 is prime.

Original entry on oeis.org

3, 3, 3, 3, 7, 7, 3, 19, 7, 3, 3, 19, 79, 7, 7, 43, 67, 139, 127, 103, 7, 97, 3, 31, 31, 13, 379, 61, 109, 433, 3, 79, 127, 79, 67, 139, 127, 229, 7, 109, 271, 313, 3, 151, 7, 103, 67, 283, 421, 67, 43, 373, 97, 97, 97, 19, 61, 3, 157, 331, 127, 37, 139, 439, 421
Offset: 0

Author

James S. DeArmon, Apr 20 2025

Keywords

Examples

			a(0) = 3, since 3 + (3^0+1) = 5 is prime and 2 + (3^0+1) = 4 is not.
a(1) = 3, since 3 + (3^1+1) = 7 is prime and 2 + (3^1+1) = 6 is not.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local t,p;
     p:= 1: t:= 3^n+1;
     do
       p:= nextprime(p);
       if isprime(p+t) then return p fi
     od;
    end proc:
    map(f, [$0..100]); # Robert Israel, Jun 19 2025
  • Mathematica
    a[n_]:=Module[{p=2},While[!PrimeQ[p+3^n+1], p=NextPrime[p]]; p]; Array[a,65,0] (* Stefano Spezia, Apr 25 2025 *)
  • PARI
    a(n) = my(p=2, x=3^n+1); while (!isprime(p+x), p=nextprime(p+1)); p; \\ Michel Marcus, Apr 24 2025
  • Python
    from sympy import isprime, nextprime
    def a(n):
        p, b = 2, 3**n+1
        while not isprime(p+b):
            p = nextprime(p)
        return p
    print([a(n) for n in range(65)]) # Michael S. Branicky, Apr 23 2025
    
  • Python
    from sympy import nextprime, isprime
    def A381041(n):
        p = 3**n+1
        q = nextprime(p)
        while not isprime(q-p):
            q = nextprime(q)
        return q-p # Chai Wah Wu, May 01 2025
    

Formula

a(n) = A020483(A007051(n)). - Robert Israel, Jun 19 2025

Extensions

More terms from Michael S. Branicky, Apr 23 2025

A382667 Position of the first instance of prime(n), in base 2, in the binary representation of Pi after the binary point.

Original entry on oeis.org

3, 11, 16, 11, 16, 15, 25, 60, 91, 14, 11, 126, 58, 393, 207, 18, 14, 13, 6, 180, 141, 169, 58, 243, 47, 326, 168, 475, 15, 291, 451, 108, 64, 87, 327, 421, 358, 41, 356, 468, 343, 16, 618, 107, 80, 179, 57, 206, 291, 325, 361, 205, 427, 12, 95, 108, 436, 6, 996
Offset: 1

Author

James S. DeArmon, Apr 02 2025

Keywords

Comments

Positions are numbered starting from 1 for the first bit after the binary point in Pi.

Examples

			For n=19, the bits of Pi and their numbering, after the binary point, begin
          1 2 3 4 5 6 7 8 9 ...
   1 1 .  0 0 1 0 0 1 0 0 0 0 1 1 1 1 ...
                    \-----------/
                    prime(19) = 67
prime(19) = 1000011_2 begins at position a(19) = 6.
prime(58) = 271 = 100001111_2 also starts at 6 => a(58) = 6.
		

Programs

  • Mathematica
    p=Drop[RealDigits[Pi,2,1010][[1]],2](* increase for n>73 *);a[n_]:=First[SequencePosition[p,IntegerDigits[Prime[n],2]][[1]]] (* James C. McMahon, Apr 26 2025 *)
  • Python
    import gmpy2
    from sympy import isprime
    gmpy2.get_context().precision = 12000000
    gmpy2.get_context().round = gmpy2.RoundDown
    pi = gmpy2.const_pi()
    binary_pi = gmpy2.digits(pi, 2)[0][2:] # Get binary digits and remove "11"
    print([binary_pi.find(bin(cand)[2:])+1 for cand in range(2, 700) if isprime(cand)])

Formula

a(n) = A178707(A000040(n)). - Pontus von Brömssen, Apr 12 2025

A382307 Position of start of first run of alternating bit values in the base-2 representation of Pi, or -1 if no such run exists.

Original entry on oeis.org

1, 2, 2, 19, 19, 19, 19, 19, 1195, 1697, 1890, 1890, 1890, 1890, 15081, 63795, 206825, 206825, 206825, 470577, 470577, 557265, 557265, 557265, 557265, 557265, 447666572, 447666572, 699793337, 699793337, 2049646803, 2250772991
Offset: 1

Author

James S. DeArmon, Mar 21 2025

Keywords

Comments

In base-2, Pi is: 11.00100100001111110110101010001... For this sequence, the integer part of Pi is ignored, and the first fractional bit is numbered one.
The bit substring may begin with either 0 or 1.
a(27) > 4*10^6. - Michael S. Branicky, Mar 23 2025
Conjecture: no term is -1 (would follow from a proof that Pi is normal in base 2). - Sean A. Irvine, Mar 30 2025
a(33) > 4*10^9. - Pontus von Brömssen, Apr 06 2025

Examples

			The first alternating bit run is "0", at position 1, so a(1) = 1. The second and third alternating bit runs are "01" and "010", starting at position 2, so a(2) and a(3) are both 2.
a(4)-a(8) = 19 since the binary digits of Pi are "10101010" starting at position 19.
		

Crossrefs

Programs

  • Python
    def binary_not(binary_string):
        return ''.join('1' if bit == '0' else '0' for bit in binary_string)
    # !pip install gmpy2   # may be necessary
    import gmpy2
    gmpy2.get_context().precision = 12000000
    pi = gmpy2.const_pi()
    # Convert Pi to binary representation
    binary_pi = gmpy2.digits(pi, 2)[0] # zero-th element is the string of bits
    binary_pi = binary_pi[2:] # remove leading "11" left of decimal point
    outVec = []
    strSearch0 = "" # this substring starts with "0"
    for lenRun in range(1,30):
      strSearch0 += "0" if lenRun%2==1 else "1"
      strSearch1 = binary_not(strSearch0)
      l0 = binary_pi.find(strSearch0)+1 # incr origin-0 result
      l1 = binary_pi.find(strSearch1)+1
      outVec.append(min(l0,l1))
    print(outVec)

Extensions

a(26)-a(32) from Pontus von Brömssen, Apr 06 2025

A381158 Prime numbers where digit values decrease while alternating parity.

Original entry on oeis.org

2, 3, 5, 7, 41, 43, 61, 83, 521, 541, 743, 761, 941, 983, 6521, 8521, 8543, 8741, 8761, 76541, 76543, 94321, 98321, 98543
Offset: 1

Author

James S. DeArmon, Feb 15 2025

Keywords

Examples

			41 is a term, since the digits decrease in value and alternate even and odd.
		

Programs

  • Maple
    b:= proc(n) `if`(isprime(n), n, [][]), seq(b(10*n+j), j=irem(n, 10)-1..1, -2) end:
    {seq(b(n), n=1..9)}[];  # Alois P. Heinz, Mar 12 2025
  • Mathematica
    ad=Select[Prime[Range[10^6]],Reverse[Union[IntegerDigits[#]]]==IntegerDigits[#]&];fQ[n_] := Block[{m = Mod[ IntegerDigits@ n, 2]}, m == Split[m, UnsameQ][[1]]];Select[ad,fQ] (* James C. McMahon, Mar 20 2025 *)
  • Python
    from sympy import isprime
    from itertools import combinations
    def ap(s): return all((s[i] in "13579") == (s[i+1] in "02468") for i in range(len(s)-1))
    def afull(): return sorted(t for d in range(1, 10) for c in combinations("987654321", d) if ap(c) and isprime(t:=int("".join(c))))
    print(afull()) # Michael S. Branicky, Mar 10 2025

A380596 Numbers with embedded palindromes as proper substrings of the term.

Original entry on oeis.org

100, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 133, 144, 155, 166, 177, 188, 199, 200, 211, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 233, 244, 255, 266, 277, 288, 299, 300, 311, 322, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 344, 355, 366, 377, 388, 399
Offset: 1

Author

James S. DeArmon, Jan 27 2025

Keywords

Comments

An embedded palindrome is a substring of at least two contiguous digits (since a single digit is trivially a palindrome). E.g., 121 is a palindrome, but has no embedded palindromes; 110 has the embedded palindrome "11".
Alternatively, k contains a proper substring of the form dd or ded, where d and e are single decimal digits (i.e., a length-2 or -3 palindrome). - Michael S. Branicky, Feb 08 2025

Examples

			100 is a term, since "00" is a palindrome; 1001 is a term for the same reason.
1020 is a term, since "020" is a palindrome; 10201 is a term for the same reason.
		

Crossrefs

Cf. A002113.
Significant overlap with A044821 for terms below 1000.

Programs

  • Python
    from itertools import combinations
    def get_all_substrings(string):
        length = len(string) + 1
        return [string[x:y] for x, y in combinations(range(length), r=2)]
    def is_palindrome(n):
        return str(n) == str(n)[::-1]
    def ok(n):
        subsets = get_all_substrings(str(n))
        subsets = [subset for subset in subsets if is_palindrome(subset) and len(subset)>1 and len(subset)0
    print([k for k in range (100,400) if ok(k)])
    
  • Python
    def ok(n):
        s = str(n)
        return any(p == p[::-1] and len(p) < len(s) for p in (s[i:i+j] for j in (2, 3) for i in range(len(s)-j+1)))
    print([k for k in range(400) if ok(k)]) # Michael S. Branicky, Feb 08 2025

A379750 First prime of cousin prime pairs which differ, in their binary representation, by a single bit.

Original entry on oeis.org

3, 19, 43, 67, 97, 163, 193, 307, 313, 379, 457, 499, 643, 673, 739, 769, 859, 883, 907, 937, 1009, 1297, 1483, 1489, 1579, 1609, 1867, 1873, 1993, 2083, 2137, 2203, 2347, 2377, 2473, 2539, 2617, 2659, 2683, 2689, 2707, 2833, 2857, 2953, 3019, 3163, 3187, 3217
Offset: 1

Author

James S. DeArmon, Jan 01 2025

Keywords

Comments

The first prime of a cousin prime pair is a prime p for which p+4 is also prime.
The only way for p and p+4 to differ at a single bit position is when p has a 0 bit at its "4" position, so p == {0,1,2,3} (mod 8), and so this sequence is the intersection of A023200 and A047471.

Examples

			3 is a term since it's a cousin prime with 7 and their respective binary representations 011 and 111 differ at a single bit position.
13 is not a term since, although it's a cousin prime with 17, their respective binary representations 1101 and 10001 differ at more than a single bit position.
		

Crossrefs

Cf. A023200 (cousin primes), A047471, A071695.

Programs

  • Mathematica
    Select[Prime[Range[480]], PrimeQ[#+4]&&Mod[#,8]<4&] (* James C. McMahon, Mar 01 2025 *)
  • Python
    import sympy
    def ok(n): return (n&5)==1 and sympy.isprime(n) and sympy.isprime(n+4)

Extensions

a(45)-a(48) from James C. McMahon, Mar 01 2025

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

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

A379150 Smallest prime ending in "3", with n preceding "0" digits.

Original entry on oeis.org

103, 2003, 70003, 100003, 1000003, 20000003, 500000003, 40000000003, 40000000003, 100000000003, 2000000000003, 230000000000003, 3100000000000003, 11000000000000003, 20000000000000003, 100000000000000003, 1000000000000000003, 310000000000000000003, 500000000000000000003
Offset: 1

Author

James S. DeArmon, Dec 16 2024

Keywords

Comments

Leading zeros are not allowed, e.g., "03".
a(997) has 1001 digits. - Michael S. Branicky, Dec 16 2024

Examples

			a(1) = 103, is the smallest prime ending in "03";
a(2) = 2003, is the smallest prime ending in "003".
		

Crossrefs

Programs

  • Mathematica
    Table[i=1;While[!PrimeQ[m=FromDigits[Join[IntegerDigits[i],Table[0,n],{3}]]],i++];m,{n,19}] (* James C. McMahon, Dec 23 2024 *)
  • PARI
    a(n)=for(i=1, oo, if(isprime(i*10^(n+1)+3), return(i*10^(n+1)+3))) \\ Johann Peters, Dec 27 2024
  • Python
    import sympy
    def prime3_finder():
      outVec = []
      power = 2
      for n in range(100,999999999):
          if not n & 3 == 3: continue # speed-up over simple MOD operation
          if not n % 10**power == 3: continue
          if not sympy.isprime(n): continue
          outVec.append(n)
          power += 1
      return outVec
    outvec = prime3_finder()
    print(outvec)
    
  • Python
    from sympy import isprime
    from itertools import count
    def a(n): return next(i for i in count(10**(n+1)+3, 10**(n+1)) if isprime(i))
    print([a(n) for n in range(1, 20)]) # Michael S. Branicky, Dec 16 2024
    

Extensions

More terms from Michael S. Branicky, Dec 16 2024