login
A181530
Greatest k <= n such that 3^n + 3^k - 1 is prime, or 0 if no such prime exists.
2
1, 2, 3, 3, 3, 5, 7, 8, 6, 8, 8, 12, 7, 6, 12, 15, 8, 13, 13, 20, 18, 20, 23, 22, 20, 8, 27, 26, 22, 26, 21, 30, 27, 20, 35, 26, 28, 28, 35, 38, 39, 22, 37, 38, 12, 45, 39, 36, 3, 30, 49, 49, 48, 37, 28, 56, 42, 53, 17, 58, 36, 62, 59, 55, 40, 26, 64, 68, 58, 61
OFFSET
1,2
EXAMPLE
For n = 4, 3^4 + 3^4 - 1 = 161 = 7*23, 3^4 + 3^3 - 1 = 107 so a(4) = 3.
For n = 154, for k = 0, 1, 2, 3, ..., 154, the numbers 3^154 + 3^k - 1 are respectively divisible by 3, 5531, 73, 5, 7, 19001, 6553, 5, 239, 3541, 7, 5, 33247, 71, 19, 5, 7, 29, 1973, 5, 436467739, 71161, 7, 5, 4283, 37, 73, 5, 7, 11177, 13721, 5, 19, 29207, 7, 5, 64849, 4001, 73, 5, 7, 31, 227009113, 5, 139, 29, 7, 5, 71, 107102231, 19, 5, 7, 10765021647412056860623883, 521, 5, 241, 1448445976112887644909473, 7, 5, 5657, 37, 73, 5, 7, 110661029, 65963, 5, 19, 20411, 7, 5, 331, 29, 73, 5, 7, 7671791, 269, 5, 563, 211, 7, 5, 6553, 113, 19, 5, 7, 425679689, 1301, 5, 334244063, 53, 7, 5, 15254167, 37, 73, 5, 7, 29, 3391, 5, 19, 7727, 7, 5, 4799, 2269, 73, 5, 7, 1822597729, 47, 5, 242496218184092003, 38971, 7, 5, 9994245487379630507640393493999, 9104413, 19, 5, 7, 3581, 1039, 5, 181, 29, 7, 5, 2472681219552827727900539, 37, 73, 5, 7, 47, 99986141, 5, 19, 1237, 7, 5, 55817, 53, 73, 5, 7, 1033, 9187, 5, 199, 71, 7. So a(154) = 0.
PROG
(PARI) a(n) = my(k=n); while (!isprime(3^n + 3^k - 1), k--; if (k==0, return (0))); k; \\ Michel Marcus, Sep 16 2019
(Magma) sol:=[]; for n in [1..70] do k:=n; while not IsPrime(3^n+3^k-1) and k gt 0 do k:=k-1; end while; if k ge 0 then Append(~sol, k); else Append(~sol, 0); end if; end for; sol; // Marius A. Burtea, Sep 16 2019
CROSSREFS
Sequence in context: A036020 A036024 A036029 * A035362 A042957 A341074
KEYWORD
nonn
AUTHOR
Pierre CAMI, Jan 29 2011
STATUS
approved