cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

User: Jonathan Deane

Jonathan Deane's wiki page.

Jonathan Deane has authored 3 sequences.

A241773 A sequence constructed by greedily sampling the Gauss-Kuzmin distribution log_2[(i+1)^2/(i^2+2*i)] to minimize discrepancy.

Original entry on oeis.org

1, 2, 3, 1, 4, 1, 5, 2, 1, 6, 1, 7, 1, 2, 3, 1, 8, 1, 9, 2, 1, 4, 1, 10, 1, 3, 2, 1, 11, 1, 2, 5, 1, 12, 1, 3, 1, 2, 4, 1, 13, 1, 2, 6, 1, 14, 1, 3, 1, 2, 15, 1, 16, 1, 2, 4, 1, 3, 1, 5, 7, 1, 2, 1, 17, 1, 2, 3, 1, 18, 1, 8, 2, 1, 4, 1, 6, 1, 2, 3, 1, 5, 1, 19
Offset: 1

Author

Jonathan Deane, Apr 28 2014

Keywords

Comments

Let the sequence be A = {a(i)}, i = 1, 2, 3,... and define p(i) =
log_2[(i+1)^2/(i^2+2*i)]. Additionally, define u(j, k) = k*p(j) - N(j, k), where N(j, k) is the number of occurrences of j in {a(i)}, i = 1,..., k-1. Refer to the first argument of u as the "index" of u. Then A is defined by a(1) = 1 and, for i > 1, a(i) = m, where m is the index of the maximal element of the set {u(j, i)}, j = 1, 2, 3,... That there is a single maximal element for all i is guaranteed by the fact that p(i) - p(j) is irrational for all i not equal to j.
Interpreting sequence A as the partial coefficients of the continued fraction expansion of a real number C, say, then C = 1.44224780173510148... which is, by construction, normal (in the continued fraction sense).
The geometric mean of the sequence equals Khintchine's constant K=2.685452001 = A002210 since the frequency of the integers agrees with the Gauss-Kuzmin distribution. - Jwalin Bhatt, Feb 11 2025

Examples

			Example from _Jwalin Bhatt_, Jun 10 2025: (Start)
Let p(k) denote the probability of k and c(k) denote the number of occurrences of k among the first n-1 terms; then the expected number of occurrences of k among n random terms is given by n*p(k).
We subtract the actual occurrences c(n) from the expected occurrences and pick the one with the highest value.
| n | n*p(1) - c(1) | n*p(2) - c(2) | n*p(3) - c(3) | choice |
|---|---------------|---------------|---------------|--------|
| 1 |     0.415     |     0.169     |     0.093     |   1    |
| 2 |    -0.169     |     0.339     |     0.186     |   2    |
| 3 |     0.245     |    -0.490     |     0.279     |   3    |
| 4 |     0.660     |    -0.320     |    -0.627     |   1    |
(End)
		

Programs

  • Maple
    pdf := i -> -log[2](1 - 1/(i+1)^2);
    gen_seq := proc(n)
    local i, j, N, A, u, mm, ndig;
    ndig := 40; N := 'N';
    for i from 1 to n do    N[i] := 0;      end do;
    A := 'A'; A[1] := 1; N[1] := 1;
    for i from 2 to n do
            u := 'u';
            for j from 1 to n do
                    u[j] := i*pdf(j) - N[j];
            end do;
            mm := max_maxind(evalf(convert(u, list), ndig));
            if mm[3] then
                    A[i] := mm[1];
                    N[mm[1]] := N[mm[1]] + 1;
            else
                    return();
            end if;
    end do;
    return(convert(A, list));
    end:
    max_maxind := proc(inl)
    local uniq, mxind, mx, i;
    uniq := `true`;
    if nops(inl) = 1 then return([1, inl[1], uniq]); end if;
    mxind := 1; mx := inl[1];
    for i from 2 to nops(inl) do
            if inl[i] > mx then
                    mxind := i;
                    mx := inl[i];
                    uniq := `true`;
            elif inl[i] = mx then
                    uniq := `false`;
            end if;
    end do;
    return([mxind, mx, uniq]);
    end:
    gen_seq(100);
  • Mathematica
    probCountDiff[j_, k_, count_] := k*-Log[2, 1 - (1/((j + 1)^2))] - Lookup[count, j, 0]
    samplePDF[n_] := Module[{coeffs, unreachedVal, counts, k, probCountDiffs, mostProbable},
      coeffs = ConstantArray[0, n]; unreachedVal = 1; counts = <||>;
      Do[probCountDiffs = Table[probCountDiff[i, k, counts], {i, 1, unreachedVal}];
        mostProbable = First@FirstPosition[probCountDiffs, Max[probCountDiffs]];
        If[mostProbable == unreachedVal, unreachedVal++]; coeffs[[k]] = mostProbable;
        counts[mostProbable] = Lookup[counts, mostProbable, 0] + 1; , {k, 1, n}]; coeffs]
    A241773 = samplePDF[120]  (* Jwalin Bhatt, Jun 04 2025 *)
  • Python
    from fractions import Fraction
    def prob_count_diff(j, k, count):
        return  - ((1 - Fraction(1,(j+1)*(j+1)))**k) * (2**count)
    def sample_pdf(n):
        coeffs, unreached_val, counts = [], 1, {}
        for k in range(1, n+1):
            prob_count_diffs = [prob_count_diff(i, k, counts.get(i, 0)) for i in range(1, unreached_val+1)]
            most_probable = prob_count_diffs.index(max(prob_count_diffs)) + 1
            unreached_val += most_probable == unreached_val
            coeffs.append(most_probable)
            counts[most_probable] = counts.get(most_probable, 0) + 1
        return coeffs
    A241773 = sample_pdf(120)  # Jwalin Bhatt, Feb 09 2025

A126684 Union of A000695 and 2*A000695.

Original entry on oeis.org

0, 1, 2, 4, 5, 8, 10, 16, 17, 20, 21, 32, 34, 40, 42, 64, 65, 68, 69, 80, 81, 84, 85, 128, 130, 136, 138, 160, 162, 168, 170, 256, 257, 260, 261, 272, 273, 276, 277, 320, 321, 324, 325, 336, 337, 340, 341, 512, 514, 520, 522, 544, 546, 552, 554, 640, 642, 648, 650
Offset: 1

Author

Jonathan Deane, Feb 15 2007, May 04 2007

Keywords

Comments

Essentially the same as A032937: 0 followed by terms of A032937. - R. J. Mathar, Jun 15 2008
Previous name was: If A = {a_1, a_2, a_3...} is the Moser-de Bruijn sequence A000695 (consisting of sums of distinct powers of 4) and A' = {2a_1, 2a_2, 2a_3...} then this sequence, let's call it B, is the union of A and A'. Its significance, alluded to in the entry for the Moser-de Bruijn sequence, is that its sumset, B+B, = {b_i + b_j : i, j natural numbers} consists of the nonnegative integers; and it is the fastest-growing sequence with this property. It can also be described as a "basis of order two for the nonnegative integers".
The sequence is the fastest growing with this property in the sense that a(n) ~ n^2, and any sequence with this property is O(n^2). - Franklin T. Adams-Watters, Jul 27 2015
Or, base 2 representation Sum{d(i)*2^(m-i): i=0,1,...,m} has even d(i) for all odd i.
Union of A000695 and 2*A000695. - Ralf Stephan, May 05 2004
Union of A000695 and A062880. - Franklin T. Adams-Watters, Aug 30 2014
Integers, the binary representation of which contains no pair of 1 bits whose difference in bit index is odd. - Frederik P.J. Vandecasteele, May 29 2025

Examples

			All nonnegative integers can be represented in the form b_i + b_j; e.g. 6 = 5+1, 7 = 5+2, 8 = 0+8, 9 = 4+5
		

Crossrefs

Programs

  • Haskell
    a126684 n = a126684_list !! (n-1)
    a126684_list = tail $ m a000695_list $ map (* 2) a000695_list where
       m xs'@(x:xs) ys'@(y:ys) | x < y     = x : m xs ys'
                               | otherwise = y : m xs' ys
    -- Reinhard Zumkeller, Dec 03 2011
    
  • Mathematica
    nmax = 100;
    b[n_] := FromDigits[IntegerDigits[n, 2], 4];
    Union[A000695 = b /@ Range[0, nmax], 2 A000695][[1 ;; nmax+1]] (* Jean-François Alcover, Oct 28 2019 *)
  • PARI
    for(n=0,350,b=binary(n); l=length(b); if(sum(i=1,floor(l/2), component(b,2*i))==0,print1(n,",")))
    
  • Python
    from gmpy2 import digits
    def A126684(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def g(x):
            s = digits(x,4)
            for i in range(l:=len(s)):
                if s[i]>'1':
                    break
            else:
                return int(s,2)
            return int(s[:i]+'1'*(l-i),2)
        def f(x): return n-1+x-g(x)-g(x>>1)
        return bisection(f,n-1,n-1) # Chai Wah Wu, Oct 29 2024

Formula

G.f.: sum(i>=1, T(i, x) + U(i, x) ), where
T := (k,x) -> x^(2^k-1)*V(k,x);
U := (k,x) -> 2*x^(3*2^(k-1)-1)*V(k,x); and
V := (k,x) -> (1-x^(2^(k-1)))*(4^(k-1) + sum(4^j*x^(2^j)/(1+x^(2^j)), j = 0..k-2))/(1-x);
Generating function. Define V(k) := [4^(k-1) + Sum ( j=0 to k-2, 4^j * x^(2^j)/(1+x^(2^j)) )] * (1-x^(2^(k-1)))/(1-x) and T(k) := (x^(2^k-1) * V(k), U(k) := x^(3*2^(k-1)-1) * V(k) then G.f. is Sum ( i >= 1, T(i) + U(i) ). Functional equation: if the sequence is a(n), n = 1, 2, 3, ... and h(x) := Sum ( n >= 1, x^a(n) ) then h(x) satisfies the following functional equation: (1 + x^2)*h(x^4) - (1 - x)*h(x^2) - x*h(x) + x^2 = 0.

Extensions

New name (using comment from Ralf Stephan) from Joerg Arndt, Aug 31 2014

A027436 G.f. f(x) = Sum_{n>=1} a(n)*x^n satisfies f(f(x)) = x*(1 + 4*x).

Original entry on oeis.org

0, 1, 2, -4, 16, -80, 432, -2304, 10944, -35328, -74112, 2736384, -30853632, 238663680, -1247457280, 2201247744, 32530722816, -320650199040, 156266184704, 18314630348800, -20667999748096, -3428200020508672
Offset: 0

Keywords

Crossrefs

Formula

a(n) = 4^(n-1) * A097088(n) / 2^A097089(n).
T(n,m) = if n=m then 1 else (binomial(m,n-m)*4^(n-m)-sum(i=m+1..n-1, T(n,i)*T(i,m)))/2. a(n) = T(n,1). - Vladimir Kruchinin, Nov 08 2011

Extensions

Added a(0)=0 (sum in title starts at a(1)), Henry Bottomley, Apr 20 2011