%I #19 Sep 18 2015 04:33:30
%S 1,2,3,4,7,6,5,8,9,12,11,14,16,21,10,22,13,24,15,26,19,31,18,32,20,23,
%T 25,29,30,28,33,34,38,40,17,36,42,27,35,44,37,48,39,50,46,41,43,47,49,
%U 51,52,56,58,60,45,53,62,55,66,57,68,61,65,67,71,54,70,64,75,74,76,80,59,72,84,63,77,86,69,81,73,90,78,94,82,79,96,88,83,85,89,93,92,98,102,91,104,101,106,111,112,114,116,121,122
%N a(n) is the smallest positive integer not in {a(1), ..., a(n - 1)} such that the sum of the least significant digit of a(n) and the most significant digit of a(n - 1) is a prime, with a(1) = 1.
%C Eric Angelini is the originator of this sequence. It is believed that the sequence is a derangement of the positive integers.
%e a(1) = 1 so a(2) >= 2. As the most significant digit of a(1)+ the least significant digit of a(2) equals 3, a prime, then a(2) = 2.
%p A201543 := proc(n)
%p option remember;
%p if n =1 then
%p 1;
%p else
%p for a from 2 do
%p if not a in [seq(procname(i),i=1..n-1)] then
%p adgs := convert(a,base,10) ;
%p a1dgs := convert(procname(n-1),base,10) ;
%p if isprime(op(1,adgs)+op(-1,a1dgs)) then
%p return a;
%p end if;
%p end if;
%p end do:
%p end if;
%p end proc:
%p for n from 1 to 120 do
%p printf("%d,",A201543(n)) ;
%p end do: # _R. J. Mathar_, Dec 14 2011
%t ericPrimer[1] := 1; SetAttributes[ericPrimer, Listable]; ericPrimer[n_] := ericPrimer[n] = Module[{iter, prevEPs = ericPrimer[Range[n - 1]], notFound = True}, iter = Complement[Range[Max[prevEPs] + 1], prevEPs][[1]]; While[notFound, While[MemberQ[prevEPs, iter], iter++]; notFound = Not[PrimeQ[IntegerDigits[iter][[1]] + IntegerDigits[prevEPs[[-1]]][[-1]]]]; If[notFound, iter++]]; Return[iter]]; ericPrimer[Range[100]] (* _Alonso del Arte_, Dec 02 2011 *)
%K nonn,base
%O 1,2
%A _Christopher Hunt Gribble_, Dec 02 2011
|