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.
%I A059168 #25 Aug 07 2023 19:04:22 %S A059168 2,3,5,7,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97, %T A059168 101,103,107,109,131,151,163,173,181,191,193,197,241,251,263,271,281, %U A059168 283,293,307,313,317,353,373,383,397,401,409,419,439,461,463,487,491 %N A059168 Primes in which digits alternately rise and fall (or vice versa); sometimes called undulating primes. %D A059168 C. A. Pickover, "Wonders of Numbers", Oxford New York 2001, Chapter 52, pp. 123-124, 316-317. %H A059168 Robert Israel, <a href="/A059168/b059168.txt">Table of n, a(n) for n = 1..10000</a> %H A059168 C. A. Pickover, "Wonders of Numbers, Adventures in Mathematics, Mind and Meaning," <a href="http://www.zentralblatt-math.org/zmath/en/search/?q=an:0983.00008&format=complete">Zentralblatt review</a> %p A059168 extend:= proc(n) local L,j; %p A059168 L:= convert(n,base,10); %p A059168 if (L[-1] < L[-2]) xor (nops(L)::odd) then %p A059168 seq(10*n+j,j=0..L[1]-1) %p A059168 else %p A059168 seq(10*n+j,j=L[1]+1..9) %p A059168 fi %p A059168 end proc: %p A059168 und[2]:= [seq(seq(10*i+j,j=subs(i=NULL,[$0..9])),i=1..9)]: %p A059168 for i from 3 to 4 do und[i]:= map(extend,und[i-1]) od: %p A059168 select(isprime, [2,3,5,7,seq(op(und[i],i=2..4)]); # _Robert Israel_, Nov 15 2018 %t A059168 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 *) %t A059168 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 *) %o A059168 (Python) %o A059168 from sympy import isprime %o A059168 def f(w,dir): %o A059168 if dir == 1: %o A059168 for s in w: %o A059168 for t in range(int(s[-1])+1,10): %o A059168 yield s+str(t) %o A059168 else: %o A059168 for s in w: %o A059168 for t in range(0,int(s[-1])): %o A059168 yield s+str(t) %o A059168 A059168_list = [] %o A059168 for l in range(5): %o A059168 for d in '123456789': %o A059168 x = d %o A059168 for i in range(1,l+1): %o A059168 x = f(x,(-1)**i) %o A059168 A059168_list.extend([int(p) for p in x if isprime(int(p))]) %o A059168 if l > 0: %o A059168 y = d %o A059168 for i in range(1,l+1): %o A059168 y = f(y,(-1)**(i+1)) %o A059168 A059168_list.extend([int(p) for p in y if isprime(int(p))]) # _Chai Wah Wu_, Apr 25 2021 %Y A059168 Cf. A032758, A059170. %K A059168 nonn,base,easy %O A059168 1,1 %A A059168 _N. J. A. Sloane_, Feb 14 2001 %E A059168 More terms from Larry Reeves (larryr(AT)acm.org), Feb 15 2001 %E A059168 Offset changed by _Robert Israel_, Nov 15 2018