

A296239


a(n) = distance from n to nearest Fibonacci number.


1



0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 16, 15, 14, 13, 12, 11, 10, 9
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,11


COMMENTS

The Fibonacci numbers correspond to sequence A000045.
This sequence is analogous to:
 A051699 (distance to nearest prime),
 A053188 (distance to nearest square),
 A053646 (distance to nearest power of 2),
 A053615 (distance to nearest oblong number),
 A053616 (distance to nearest triangular number),
 A061670 (distance to nearest power),
 A074989 (distance to nearest cube),
 A081134 (distance to nearest power of 3),
The local maxima of the sequence correspond to positive terms of A004695.
a(n) = 0 iff n = A000045(k) for some k >= 0.
a(n) = 1 iff n = A061489(k) for some k > 4.
For any n >= 0, abs(a(n+1)  a(n)) <= 1.
For any n > 0, a(n) < n, and a^k(n) = 0 for some k > 0 (where a^k denotes the kth iterate of a); k equals A105446(n) for n = 1..80 (and possibly more values).
a(n) > max(a(n1), a(n+1)) iff n = A001076(k) for some k > 1.


LINKS

Table of n, a(n) for n=0..80.
Index entries for sequences related to distance to nearest element of some set


FORMULA

a(n) = abs(n  Fibonacci(floor(log(sqrt(20)*n)/log((1 + sqrt(5))/2)1))).  Jon E. Schoenfield, Dec 14 2017


EXAMPLE

For n = 42:
 A000045(9) = 34 <= 42 <= 55 = A000045(10),
 a(42) = min(42  34, 55  42) = min(8, 13) = 8.


MATHEMATICA

fibPi[n_] := 1 + Floor[ Log[ GoldenRatio, 1 + n*Sqrt@5]]; f[n_] := Block[{m = fibPi@ n}, Min[n  Fibonacci[m 1], Fibonacci[m]  n]]; Array[f, 81, 0] (* Robert G. Wilson v, Dec 11 2017 *)


PROG

(PARI) a(n) = for (i=1, oo, if (n<=fibonacci(i), return (min(nfibonacci(i1), fibonacci(i)n))))


CROSSREFS

Cf. A000045, A001076, A004695, A051699, A053188, A053615, A053616, A053646, A061489, A061670, A074989, A081134, A105446.
Sequence in context: A109389 A098884 A297964 * A039800 A251418 A172101
Adjacent sequences: A296236 A296237 A296238 * A296240 A296241 A296242


KEYWORD

nonn,easy


AUTHOR

Rémy Sigrist, Dec 09 2017


STATUS

approved



