login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Numbers written in Jacobsthal greedy base.
14

%I #45 Jan 05 2025 19:51:40

%S 0,1,2,10,11,100,101,102,110,111,200,1000,1001,1002,1010,1011,1100,

%T 1101,1102,1110,1111,10000,10001,10002,10010,10011,10100,10101,10102,

%U 10110,10111,10200,11000,11001,11002,11010,11011,11100,11101,11102,11110,11111,20000,100000,100001,100002,100010,100011,100100

%N Numbers written in Jacobsthal greedy base.

%C These are called "Jacobsthal Representation Numbers" in Horadam's 1996 paper.

%C Sum_{i=0..} digit(i)*A001045(2+digit(i)) recovers n from such representation a(n), where digit(0) stands for the least significant digit (at the right), and A001045(k) gives the k-th Jacobsthal number.

%C No larger digits than 2 will occur, which allows representing the same sequence in a more compact form by base-3 coding in A265746.

%C Sequence A197911 gives the terms with no digit "2" in their representation, while its complement A003158 gives the terms where "2" occurs at least once.

%C Numbers beginning with digit "2" in this representation are given by A020988(n) [= 2*A002450(n) = 2*A001045(2n)].

%H Antti Karttunen, <a href="/A265747/b265747.txt">Table of n, a(n) for n = 0..10923</a>

%H A. F. Horadam, <a href="https://web.archive.org/web/2024*/https://www.fq.math.ca/Scanned/34-1/horadam2.pdf">Jacobsthal Representation Numbers</a>, Fib Quart. 34 (1996), 40-54. (See especially page 50, which is page 11 in PDF.)

%F a(0) = 0; for n >= 1, a(n) = 10^(A130249(n)-2) + a(n-A001045(A130249(n))).

%F a(n) = A007089(A265746(n)).

%e 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".

%e For n=10, we need A001045(4) + A001045(4) = 5+5, thus a(10) = "200".

%t 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 *)

%o (Scheme, with memoization-macro definec)

%o (definec (A265747 n) (if (zero? n) n (+ (expt 10 (- (A130249 n) 2)) (A265747 (- n (A001045 (A130249 n)))))))

%o (Python)

%o def greedyJ(n): m = (3*n+1).bit_length() - 1; return (m, (2**m-(-1)**m)//3)

%o def a(n):

%o if n == 0: return 0

%o place, value = greedyJ(n)

%o return 10**(place-2) + a(n - value)

%o print([a(n) for n in range(49)]) # _Michael S. Branicky_, Jul 11 2021

%o (PARI)

%o A130249(n) = floor(log(3*n + 1) / log(2));

%o A001045(n) = (2^n - (-1)^n) / 3;

%o 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

%Y Cf. A001045, A002450, A020988, A007089, A197911, A003158.

%Y Cf. A265745 (sum of digits).

%Y Cf. A265746 (same numbers interpreted in base-3, then shown in decimal).

%Y Cf. A084639 (positions of repunits).

%Y Cf. A007961, A014417, A014418, A244159 for analogous sequences.

%K nonn,base

%O 0,3

%A _Antti Karttunen_, Dec 17 2015