A361902 Least k such that n+A000045(k) is prime, or -1 if no such k exists.
3, 1, 0, 0, 1, 0, 1, 0, 4, 3, 1, 0, 1, 0, 4, 3, 1, 0, 1, 0, 4, 3, 1, 0, 5, 9, 4, 3, 1, 0, 1, 0, 5, 6, 4, 3, 1, 0, 4, 3, 1, 0, 1, 0, 4, 3, 1, 0, 5, 9, 4, 3, 1, 0, 5, 9, 4, 3, 1, 0, 1, 0, 5, 6, 4, 3, 1, 0, 4, 3, 1, 0, 1, 0, 5, 6, 4, 3, 1, 0, 4, 3, 1, 0, 5, 12, 4
Offset: 0
Keywords
Examples
The first Fibonacci number F such that 25+F is prime is F = 34 = A000045(9), so a(25) = 9.
Links
- Pontus von Brömssen, Table of n, a(n) for n = 0..7122
- Robert Gerbicz, Re: Add a Fibonacci number to get a prime, SeqFan mailing list, March 28, 2023.
Crossrefs
Programs
-
Mathematica
a[n_] := Module[{k = 0}, While[! PrimeQ[n + Fibonacci[k]], k++]; k]; Array[a, 100, 0] (* Amiram Eldar, Mar 30 2023 *)
-
PARI
a(n) = my(k=0); while (!isprime(n+fibonacci(k)), k++); k; \\ Michel Marcus, Mar 30 2023
-
Python
from sympy import isprime,fibonacci from itertools import count def A361902(n): # Note: the function hangs if a(n) = -1. return next(k for k in count() if isprime(n+fibonacci(k)))
Formula
a(n) = 0 if and only if n is prime.
a(n) = -1 if n == 14475 (mod m), where m = 2*3*5*7*11*23*31 = 1647030 (see Gerbicz link).
Comments