login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A215023 NegaFibonacci representation for -n. 11

%I #36 Jan 22 2020 23:30:58

%S 0,10,1001,1000,1010,100101,100100,100001,100000,100010,101001,101000,

%T 101010,10010101,10010100,10010001,10010000,10010010,10000101,

%U 10000100,10000001,10000000,10000010,10001001,10001000,10001010,10100101,10100100,10100001,10100000

%N NegaFibonacci representation for -n.

%C Let F_{-n} be the negative Fibonacci numbers (as defined in the first comment in A039834): F_{-1}=1, F_{-2}=-1, F_{-3}=2, F_{-4}=-3, F_{-5}=5, ..., F_{-n}=(-1)^(n-1)F_n.

%C Every integer has a unique representation as n = Sum_{k=1..r} c_k F_{-k} for some r, where the c_k are 0 or 1 and no two adjacent c's are 1.

%C Then a(n) = c_r ... c_3 c_2 c_1.

%D Donald E. Knuth, The Art of Computer Programming, Volume 4A, Combinatorial algorithms, Part 1, Addison-Wesley, 2011, pp. 168-171.

%H Amiram Eldar, <a href="/A215023/b215023.txt">Table of n, a(n) for n = 0..10000</a>

%H M. W. Bunder, <a href="https://www.fq.math.ca/Scanned/30-2/bunder.pdf">Zeckendorf representations using negative Fibonacci numbers</a>, The Fibonacci Quarterly, Vol. 30, No. 2 (1992), pp. 111-115.

%H Donald E. Knuth, <a href="http://www.cs.utsa.edu/~wagner/knuth/fasc1a.pdf">The Art of Computer Programming, Volume 4, Fascicle 1: Bitwise Tricks & Techniques; Binary Decision Diagrams</a>, a pre-publication draft of section 7.1.3, 2009, pp. 36-39.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/NegaFibonacci_coding">NegaFibonacci coding</a>.

%e -4 = -3 - 1 = F_{-4} + F_{-2}, so a(4) = 1010.

%t ind[n_] := Floor[Log[Abs[n]*Sqrt[5] + 1/2]/Log[GoldenRatio]]; f[1] = 1; f[n_] := If[n > 0, i = ind[n - 1]; If[EvenQ[i], i++]; i, i = ind[-n]; If[OddQ[i], i++]; i]; a[n_] := Module[{k = n, s = 0}, While[k != 0, i = f[k]; s += 10^(i - 1); k -= Fibonacci[-i]]; s]; Table[a[n], {n, 0, -100, -1}] (* _Amiram Eldar_, Oct 15 2019 *)

%o (PARI) a(n)=my(s=0,k=0,v);while(s<n,s+=fibonacci(k+=2));v=binary(2^k\2);n-=fibonacci(k);forstep(i=k-2,1,-1,if(abs(n+fibonacci(-i))<abs(n), n+=fibonacci(-i);v[#v+1-i]=1;i--));subst(Pol(v),x,10) \\ _Charles R Greathouse IV_, Aug 03 2012 [Caution: returns wrong values for some values of n > 17. _Amiram Eldar_, Oct 15 2019]

%Y Cf. A039834, A215022, A215025, A000045, A014417, A003714.

%K nonn,base

%O 0,2

%A _N. J. A. Sloane_, Aug 03 2012

%E a(18) inserted by _Amiram Eldar_, Oct 11 2019

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 03:06 EDT 2024. Contains 371696 sequences. (Running on oeis4.)