login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A181523
Greatest k < n such that 3^n - 3^k + 1 is prime or 0 if no such prime exists.
3
0, 1, 2, 2, 4, 5, 6, 4, 7, 9, 6, 10, 3, 10, 12, 0, 16, 17, 12, 17, 12, 3, 20, 22, 21, 17, 22, 0, 0, 22, 30, 29, 11, 31, 32, 18, 17, 35, 35, 37, 12, 25, 38, 14, 15, 12, 42, 37, 35, 42, 42, 36, 40, 52, 54, 16, 48, 57, 35, 58
OFFSET
1,3
MAPLE
A181523 := proc(n) local p, k; for k from n-1 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:
seq(A181523(n), n=1..80) ; # R. J. Mathar, Jan 31 2011
PROG
(Sage)
A181523 = lambda n: next((k for k in reversed(IntegerRange(1, n)) if is_pseudoprime(3^n-3^k+1)), 0) # D. S. McNeil, Jan 31 2011
CROSSREFS
Cf. A181515.
Sequence in context: A137413 A010848 A133937 * A353855 A353847 A181537
KEYWORD
nonn
AUTHOR
Pierre CAMI, Jan 29 2011
STATUS
approved