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.

A059168 Primes in which digits alternately rise and fall (or vice versa); sometimes called undulating primes.

Original entry on oeis.org

2, 3, 5, 7, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 131, 151, 163, 173, 181, 191, 193, 197, 241, 251, 263, 271, 281, 283, 293, 307, 313, 317, 353, 373, 383, 397, 401, 409, 419, 439, 461, 463, 487, 491
Offset: 1

Views

Author

N. J. A. Sloane, Feb 14 2001

Keywords

References

  • C. A. Pickover, "Wonders of Numbers", Oxford New York 2001, Chapter 52, pp. 123-124, 316-317.

Crossrefs

Programs

  • Maple
    extend:= proc(n) local L,j;
      L:= convert(n,base,10);
      if (L[-1] < L[-2]) xor (nops(L)::odd) then
        seq(10*n+j,j=0..L[1]-1)
      else
        seq(10*n+j,j=L[1]+1..9)
      fi
    end proc:
    und[2]:= [seq(seq(10*i+j,j=subs(i=NULL,[$0..9])),i=1..9)]:
    for i from 3 to 4 do und[i]:= map(extend,und[i-1]) od:
    select(isprime, [2,3,5,7,seq(op(und[i],i=2..4)]); # Robert Israel, Nov 15 2018
  • Mathematica
    d[n_]:=Differences[IntegerDigits[n]]; mQ[n_]:=MemberQ[d[n],0]==False; a[n_]:=DeleteDuplicates[Sign[Take[d[n],{1,-1,2}]]]; b[n_]:=DeleteDuplicates[Sign[Take[d[n],{2,-1,2}]]]; t={}; Do[p=Prime[n]; If[mQ[p],If[Length[IntegerDigits[p]]<=2,AppendTo[t,p],If[Length[a[p]]==Length[b[p]]==1 && a[p][[1]]!=b[p][[1]],AppendTo[t,p]]]],{n,95}]; t (* Jayanta Basu, May 08 2013 *)
    Table[Which[p<10,p,p<100&&Differences[IntegerDigits[p]]!={0},p,p>100&&Union[Total/@ Partition[Sign[Differences[IntegerDigits[p]]],2,1]]=={0},p,True,Nothing],{p,Prime[ Range[ 150]]}] (* Harvey P. Dale, Aug 07 2023 *)
  • Python
    from sympy import isprime
    def f(w,dir):
        if dir == 1:
            for s in w:
                for t in range(int(s[-1])+1,10):
                    yield s+str(t)
        else:
            for s in w:
                for t in range(0,int(s[-1])):
                    yield s+str(t)
    A059168_list = []
    for l in range(5):
        for d in '123456789':
            x = d
            for i in range(1,l+1):
                x = f(x,(-1)**i)
            A059168_list.extend([int(p) for p in x if isprime(int(p))])
            if l > 0:
                y = d
                for i in range(1,l+1):
                    y = f(y,(-1)**(i+1))
                A059168_list.extend([int(p) for p in y if isprime(int(p))]) # Chai Wah Wu, Apr 25 2021

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Feb 15 2001
Offset changed by Robert Israel, Nov 15 2018