# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a061448 Showing 1-1 of 1 %I A061448 #24 Oct 26 2019 18:00:37 %S A061448 2,23,31,101,103,307,701,1009,9001,10007,70001,100003,300007,700001, %T A061448 1000003,3000017,7000003,30000001,100000007,700000001,1000000007, %U A061448 7000000001,10000000019,90000000019,90000000023,300000000077 %N A061448 a(1) = 2; a(n+1) = smallest prime > a(n) with leading digit equal to final digit of a(n). %C A061448 From _R. J. Mathar_, Feb 15 2012: (Start) %C A061448 Starting with other primes we find: %C A061448 3, 31, 101, 103, 307, 701, 1009, 9001, 10007,.. or %C A061448 5, 53, 307, 701, 1009, 9001, 10007, 70001, 10000.... or %C A061448 7, 71, 101, 103, 307, 701, 1009, 9001, 10007, 70001 .. or %C A061448 11, 13, 31, 101, 103, 307, 701, 1009, 9001,.. or %C A061448 13, 31, 101, 103, 307, 701, 1009, 9001,.. or %C A061448 17, 71, 101, 103, 307, 701, 1009, 9001, 10007,.. or %C A061448 19, 97, 701, 1009, 9001, 10007, 70001, 100003,.. (End) %H A061448 Index entries for sequences related to final digits of numbers %F A061448 a(n) = A054262(n-1), n>2. - _R. J. Mathar_, Jan 30 2009 %e A061448 a(5) = 103, hence a(6) = 307. %p A061448 A061448 := proc(n) %p A061448 option remember; %p A061448 local a,sdig,adgs,ad ; %p A061448 if n = 1 then %p A061448 2; %p A061448 else %p A061448 sdig := procname(n-1) mod 10 ; %p A061448 a := nextprime(procname(n-1)) ; %p A061448 while true do %p A061448 adgs := convert(a,base,10) ; %p A061448 ad := op(-1,adgs) ; %p A061448 if op(-1,adgs) = sdig then %p A061448 if isprime(a) then %p A061448 return a; %p A061448 end if; %p A061448 elif ad > sdig then %p A061448 a := sdig*10^nops(adgs) ; %p A061448 elif ad < sdig then %p A061448 a := sdig*10^(nops(adgs)-1) ; %p A061448 end if; %p A061448 a := nextprime(a) ; %p A061448 end do: %p A061448 end if; %p A061448 end proc: # _R. J. Mathar_, Feb 15 2013 %t A061448 a[1]=2; a[n_] := (v=IntegerDigits[a[n-1]]; v1=If[v[[ -1]]>v[[1]], v[[ -1]]*10^(Length[v]-1), If[v[[ -1]]