A343591 Smoothly undulating alternating primes.
2, 3, 5, 7, 23, 29, 41, 43, 47, 61, 67, 83, 89, 101, 181, 383, 727, 787, 929, 18181, 32323, 72727, 74747, 78787, 94949, 1212121, 1616161, 323232323, 383838383, 727272727, 929292929, 989898989, 12121212121, 14141414141, 32323232323, 383838383838383, 38383838383838383, 72727272727272727
Offset: 1
Examples
1616161 is a term as it is prime and the digits 1 and 6 have odd and even parity and alternate.
References
- Charles W. Trigg, Special Palindromic Primes, Journal of Recreational Mathematics, 4 (July 1971) 169-170.
Links
- Robert Israel, Table of n, a(n) for n = 1..69
- Mathematics Stack Exchange, (Unsolved) In this infinite sequence, no term is a prime: prove/disprove.
Programs
-
Maple
f:= proc(n) local i,a,b,c,d; c:= add(10^i,i=1..n-1,2); d:= add(10^i,i=0..n-1,2); if n = 2 then op(select(isprime,[seq(seq(a*c+b*d, b=[1,3,7,9]),a=[2,4,6,8])])) else op(select(isprime, [seq(seq(a*c+b*d, a=[0,2,4,6,8]),b=[1,3,7,9])])) fi end proc: f(1):= (2,3,5,7): map(f, [1,2,seq(i,i=3..17,2)]); # Robert Israel, Nov 09 2023
-
Mathematica
f[o_,e_,n_,m_] := FromDigits @ Riffle[ConstantArray[o,n], ConstantArray[e,n-m]]; seq[n_,m_] := Module[{o = Range[1,9,2], e = Range[0,8,2]}, Select[Union[f @@@ Join[Tuples[{o, e, {n}, {m}}], Tuples[{Rest @ e, o, {n}, {m}}]]], PrimeQ]]; s = seq[1, 1]; Do[s = Join[s, seq[m, Boole[m > 1]]], {m, 1, 10}]; s (* Amiram Eldar, Apr 21 2021 *)
-
Python
from sympy import isprime def agenthru(maxdigits): if maxdigits >= 1: yield from [2, 3, 5, 7] for digits in [2]*(maxdigits >= 2) + list(range(3, maxdigits+1, 2)): hlf, odd = (digits+1)//2, digits%2 d1range = "1379" if digits%2 == 1 else "123456789" d2range = "1379" if digits%2 == 0 else "0123456789" for d1 in d1range: for d2 in d2range: if int(d1)%2 == int(d2)%2: continue t = int("".join([*sum(zip(d1*hlf, d2*(digits-hlf)), ())]+[d1*odd])) if isprime(t): yield t print([p for p in agenthru(17)]) # Michael S. Branicky, Apr 21 2021
Comments