login
a(1) = 1; if a(n-1) + n is prime then a(n) = a(n-1) + n, else a(n) = a(n-1).
3

%I #13 Apr 28 2018 13:35:25

%S 1,3,3,7,7,13,13,13,13,23,23,23,23,37,37,53,53,71,71,71,71,71,71,71,

%T 71,97,97,97,97,127,127,127,127,127,127,163,163,163,163,163,163,163,

%U 163,163,163,163,163,211,211,211,211,263,263,317,317,373,373,431,431,491

%N a(1) = 1; if a(n-1) + n is prime then a(n) = a(n-1) + n, else a(n) = a(n-1).

%H Michael De Vlieger, <a href="/A083743/b083743.txt">Table of n, a(n) for n = 1..10000</a>

%p a := proc(n) option remember: if n=1 then RETURN(1) fi: if isprime(a(n-1)+n) then RETURN(a(n-1)+n) else RETURN(a(n-1)) fi: end: for n from 1 to 100 do printf(`%d,`,a(n)) od: # _James A. Sellers_, May 19 2003

%t a083743[n_] := Block[{i, t = Table[1, {n}]},

%t For[i = 1, i < n,

%t If[PrimeQ[t[[i - 1]] + i], t[[i]] = t[[i - 1]] + i,

%t t[[i]] = t[[i - 1]]], i++]; t]; a083743[60] (* _Michael De Vlieger_, Dec 24 2014 *)

%t nxt[{n_,a_}]:={n+1,If[PrimeQ[a+n+1],a+n+1,a]}; NestList[nxt,{1,1},60][[All,2]] (* _Harvey P. Dale_, Apr 28 2018 *)

%K easy,nonn

%O 1,2

%A _Amarnath Murthy_, May 05 2003

%E More terms from _James A. Sellers_, May 19 2003