%I #16 Jan 30 2019 17:25:41
%S 1,2,2,4,5,6,6,2,9,6,9,0,9,12,14,16,17,15,10,18,18,13,9,22,21,18,21,
%T 16,0,30,24,11,29,9,26,32,18,15,34,39,29,37,24,27,33,31,0,30,30,15,40,
%U 43,35,54,45,42,57,51,8,60
%N Greatest k <= n such that 3^n + 3^k + 1 is prime or 0 if no such prime exists.
%H Pierre CAMI, <a href="/A181537/b181537.txt">Table of n, a(n) for n = 1..2000</a>
%p A181537 := proc(n) local p,k; for k from n to 0 by -1 do p := 3^n+3^k+1 ; if isprime(p) then return k; end if; end do: return 0 ; end proc: # _R. J. Mathar_, Jan 30 2011
%t gk[n_]:=Module[{k=n,t=3^n+1},While[!PrimeQ[t+3^k]&&k>0,k--];k]; Array[ gk,60] (* _Harvey P. Dale_, Jan 30 2019 *)
%Y Cf. A181530.
%K nonn
%O 1,2
%A _Pierre CAMI_, Jan 29 2011
|