A265747 Numbers written in Jacobsthal greedy base.
0, 1, 2, 10, 11, 100, 101, 102, 110, 111, 200, 1000, 1001, 1002, 1010, 1011, 1100, 1101, 1102, 1110, 1111, 10000, 10001, 10002, 10010, 10011, 10100, 10101, 10102, 10110, 10111, 10200, 11000, 11001, 11002, 11010, 11011, 11100, 11101, 11102, 11110, 11111, 20000, 100000, 100001, 100002, 100010, 100011, 100100
Offset: 0
Examples
For n=7, when selecting the terms of A001045 with the greedy algorithm, we need terms A001045(4) + A001045(2) + A001045(2) = 5 + 1 + 1, thus a(7) = "102". For n=10, we need A001045(4) + A001045(4) = 5+5, thus a(10) = "200".
Links
- Antti Karttunen, Table of n, a(n) for n = 0..10923
- A. F. Horadam, Jacobsthal Representation Numbers, Fib Quart. 34 (1996), 40-54. (See especially page 50, which is page 11 in PDF.)
Crossrefs
Programs
-
Mathematica
jacob[n_] := (2^n - (-1)^n)/3; maxInd[n_] := Floor[Log2[3*n + 1]]; A265747[n_] := A265747[n] = 10^(maxInd[n] - 2) + A265747[n - jacob[maxInd[n]]]; A265747[0] = 0; Array[A265747, 100, 0] (* Amiram Eldar, Jul 21 2023 *)
-
PARI
A130249(n) = floor(log(3*n + 1) / log(2)); A001045(n) = (2^n - (-1)^n) / 3; A265747(n) = {if(n==0, 0, my(d=n - A001045(A130249(n))); 10^(A130249(n)-2) + if(d == 0, 0, A265747(d)));} \\ Amiram Eldar, Jul 21 2023
-
Python
def greedyJ(n): m = (3*n+1).bit_length() - 1; return (m, (2**m-(-1)**m)//3) def a(n): if n == 0: return 0 place, value = greedyJ(n) return 10**(place-2) + a(n - value) print([a(n) for n in range(49)]) # Michael S. Branicky, Jul 11 2021
Comments