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: Jwalin Bhatt

Jwalin Bhatt's wiki page.

Jwalin Bhatt has authored 37 sequences. Here are the ten most recent ones:

A386904 A sequence constructed by greedily sampling the Borel distribution for parameter value 1/2 to minimize discrepancy.

Original entry on oeis.org

1, 2, 1, 1, 3, 1, 4, 1, 2, 1, 1, 5, 1, 2, 1, 1, 3, 1, 1, 2, 1, 6, 1, 1, 2, 1, 1, 3, 1, 2, 1, 4, 1, 1, 2, 1, 1, 7, 1, 2, 1, 3, 1, 1, 8, 1, 2, 1, 1, 5, 1, 2, 1, 1, 3, 1, 1, 2, 1, 4, 1, 1, 2, 1, 3, 1, 1, 2, 1, 1, 9, 1, 2, 1, 1, 4, 1, 3, 1, 2, 1, 1, 6, 1, 2, 1, 1, 1, 3, 1, 2, 1, 5, 1, 1, 2, 1, 1, 4, 1, 2, 1, 3, 1, 1, 2, 1, 1, 10
Offset: 1

Author

Jwalin Bhatt, Aug 07 2025

Keywords

Comments

The geometric mean approaches A386009 in the limit.
The Borel distribution with parameter value 1/2 has PDF p(i) = (i/2)^(i-1) / (exp(i/2)*i!).

Examples

			Let p(k) denote the probability of k and c(k) denote the count of occurrences of k so far, then the expected occurrences of k at n-th step are given by n*p(k).
We subtract the actual occurrences c(k) 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.606     |       -       |       -       |   1    |
| 2 |     0.213     |     0.367     |       -       |   2    |
| 3 |     0.819     |    -0.448     |     0.251     |   1    |
| 4 |     0.426     |    -0.264     |     0.334     |   1    |
| 5 |     0.032     |    -0.080     |     0.418     |   3    |
		

Crossrefs

Programs

  • Mathematica
    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]
    A386904=samplePDF[120]

A386950 A sequence constructed by greedily sampling the pdf (H(10)-H(i))/10, where H(n) is the n-th Harmonic number and the support is [0,9], to minimize discrepancy.

Original entry on oeis.org

0, 1, 0, 2, 3, 0, 1, 4, 0, 2, 5, 1, 0, 3, 0, 1, 6, 2, 4, 0, 1, 0, 3, 2, 7, 0, 5, 1, 0, 2, 4, 1, 3, 0, 0, 1, 6, 2, 0, 3, 5, 1, 4, 8, 0, 2, 0, 1, 0, 3, 2, 1, 0, 4, 7, 0, 5, 1, 6, 2, 3, 0, 1, 0, 2, 4, 0, 1, 3, 0, 2, 5, 1, 0, 0, 3, 4, 1, 6, 2, 0, 1, 0, 7, 2, 3, 0
Offset: 1

Author

Jwalin Bhatt, Aug 10 2025

Keywords

Comments

The pdf of the sequence is the probability to see i as the remainder when you divide 1,2,3... with a random number from [1,10].
The respective probabilities are:
p(0) = 7381/25200 = 0.292896...
p(1) = 4861/25200 = 0.192896...
p(2) = 3601/25200 = 0.142896...
p(3) = 2761/25200 = 0.109563...
p(4) = 2131/25200 = 0.084563...
p(5) = 1627/25200 = 0.064563...
p(6) = 1207/25200 = 0.047896...
p(7) = 121/3600 = 0.033611...
p(8) = 19/900 = 0.021111...
p(9) = 1/100 = 0.01
The sequence repeats after 25200 terms. If the random number is picked from [1,n] the period of the sequence is given by n*lcm{1,2,...,n} (A081528).
The arithmetic mean of this sequence is 2.25.
For a sequence with length n, the n-th root of the product of nonzero terms is (2**(5333/12600))*(3**(559/3150))*(5**(1627/25200))*(7**(121/3600)) which is 1.9302557640832...

Examples

			Let p(k) denote the probability of k and c(k) denote the number of occurrences of k among the first n-1 terms.
We take the ratio of the actual occurrences c(k)+1 to the probability and pick the one with the lowest value.
Since p(k) is monotonic decreasing, we only need to compute c(k) once we see c(k-1).
| n | (c(0)+1)/p(0) | (c(1)+1)/p(1) | (c(2)+1)/p(2) | choice |
|---|---------------|---------------|---------------|--------|
| 1 |     3.414     |       -       |       -       |   0    |
| 2 |     6.828     |     5.181     |       -       |   1    |
| 3 |     6.828     |    10.362     |     6.998     |   0    |
| 4 |    10.242     |    10.362     |     6.998     |   2    |
		

Crossrefs

Cf. A081528.

Programs

  • Mathematica
    samplePDF[numCoeffs_] := Module[{coeffs, counts},
      coeffs = {}; counts = ConstantArray[0, 10];
      Do[
        minTime = Infinity;
        Do[
          time = 10*(counts[[i]] + 1)/(HarmonicNumber[10] - HarmonicNumber[i - 1]);
          If[time < minTime,minIndex = i;minTime = time],{i, 1, 10}];
        counts[[minIndex]] += 1;
        coeffs = Append[coeffs, minIndex - 1],
        {numCoeffs}
       ];
      coeffs
     ]
    A386950 = samplePDF[120]
  • Python
    from sympy import harmonic
    def sample_pdf(num_coeffs):
      coeffs, counts = [], [0]*10
      for _ in range(num_coeffs):
        min_time = float('inf')
        for i, count in enumerate(counts):
          time = 10*(count+1) / (harmonic(10)-harmonic(i))
          if time < min_time:
            min_index, min_time = i, time
        counts[min_index] += 1
        coeffs.append(min_index)
      return coeffs
    A386950 = sample_pdf(120)

A385873 A sequence constructed by greedily sampling the Poisson distribution for parameter value 1 so as to minimize discrepancy.

Original entry on oeis.org

1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 4, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 1, 2, 1, 1, 3, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 5, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 2, 1, 4
Offset: 1

Author

Jwalin Bhatt, Jul 11 2025

Keywords

Comments

The geometric mean approaches A385686 = exp((Sum_{k>=2} log(k)/k!)/(e-1)) in the limit.
The Poisson distribution used here is p(i) = 1/((e-1)*i!).

Examples

			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(k) 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.581     |     0.290     |     0.096     |   1    |
| 2 |     0.163     |     0.581     |     0.193     |   2    |
| 3 |     0.745     |    -0.127     |     0.290     |   1    |
| 4 |     0.327     |     0.163     |     0.387     |   3    |
| 5 |     0.909     |     0.454     |    -0.515     |   1    |
		

Crossrefs

Programs

  • Mathematica
    probCountDiff[j_, k_, count_]:=N[k/((E-1)*Factorial[j])]-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]
    A385873=samplePDF[120]

A386016 A sequence constructed by greedily sampling the Borel distribution for parameter value 1/2 to minimize ratio discrepancy.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 1, 2, 1, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 1, 3, 1, 1, 2, 1, 1, 1, 2, 1, 1, 3, 1, 5, 1, 2, 1, 1, 1, 2, 4, 1, 1, 3, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 6, 3, 2, 1, 1, 1, 2, 1, 4, 1, 1, 2, 1, 3, 1, 1, 5, 1, 2, 1, 1, 1, 2, 1, 3, 1, 1, 2, 1, 4, 1, 1, 7
Offset: 1

Author

Jwalin Bhatt, Jul 14 2025

Keywords

Comments

The geometric mean approaches A386009 in the limit.
The Borel distribution has PDF p(i) = (i/2)^(i-1) / (exp(i/2)*i!).

Examples

			Let p(k) denote the probability of k and c(k) denote the count of occurrences of k so far.
We take the ratio of the actual occurrences c(k)+1 to the probability and pick the one with the lowest value.
Since p(k) is monotonic decreasing, we only need to compute c(k) once we see c(k-1).
| n | (c(1)+1)/p(1) | (c(2)+1)/p(2) | (c(3)+1)/p(3) | choice |
|---|---------------|---------------|---------------|--------|
| 1 |     1.648     |       -       |       -       |   1    |
| 2 |     3.297     |     5.436     |       -       |   1    |
| 3 |     4.946     |     5.436     |       -       |   1    |
| 4 |     6.594     |     5.436     |       -       |   2    |
| 5 |     6.594     |    10.873     |    11.951     |   1    |
		

Crossrefs

Programs

  • Mathematica
    pdf[i_] := ((i/2)^(i - 1))/((E^(i/2)) * Factorial[i])
    samplePDF[numCoeffs_] := Module[
      {coeffs = {}, counts = {0}, minTime, minIndex, time},
    Do[
        minTime = Infinity;
        Do[
          time = (counts[[i]] + 1)/pdf[i];
          If[time < minTime, minIndex = i; minTime = time],
          {i, 1, Length[counts]}
        ];
        If[minIndex == Length[counts], AppendTo[counts, 0]];
        counts[[minIndex]] += 1;
        AppendTo[coeffs, minIndex],
        {numCoeffs}
      ];
      coeffs
    ]
    A386016 = samplePDF[120]

A386009 Decimal expansion of Product_{k>=2} k^( ((k/2)^(k-1)) / (exp(k/2)*k!) ).

Original entry on oeis.org

1, 5, 4, 9, 2, 5, 1, 0, 4, 3, 4, 2, 5, 6, 3, 4, 0, 4, 8, 4, 0, 0, 5, 4, 4, 0, 2, 8, 1, 5, 8, 9, 4, 3, 5, 5, 5, 3, 0, 8, 8, 3, 5, 2, 6, 7, 0, 1, 5, 8, 3, 6, 8, 5, 4, 7, 2, 3, 3, 4, 6, 6, 4, 9, 5, 4, 7, 2, 2, 4, 6, 5, 2, 1, 8, 3, 3, 4, 7, 1, 6, 1, 9, 4, 2
Offset: 1

Author

Jwalin Bhatt, Jul 14 2025

Keywords

Comments

The geometric mean of the Borel distribution with parameter value 1/2 (A386016) approaches this constant. In general, for parameter value p it approaches Product_{k>=2} k^(((p*k)^(k-1))/((e^(p*k))*k!)).

Examples

			1.549251043425634048400544028158943555...
		

Crossrefs

Cf. A386016.

Programs

  • Mathematica
    Exp[NSum[((k/2)^(k-1) * Log[k])/(E^(k/2) * Factorial[k]), {k, 2, Infinity}, WorkingPrecision -> 120, NSumTerms -> 1000]]

Formula

Equals exp( Sum_{k>=2} log(k) * (((k/2)^(k-1)) / (exp(k/2)*k!)) ).

A385686 Decimal expansion of exp((Sum_{k>=2} log(k)/k!)/(e-1)).

Original entry on oeis.org

1, 4, 2, 1, 0, 3, 7, 9, 5, 9, 7, 3, 1, 9, 6, 0, 7, 1, 5, 3, 3, 7, 8, 1, 4, 4, 8, 9, 0, 5, 9, 2, 8, 5, 6, 9, 5, 3, 9, 8, 2, 5, 7, 1, 7, 4, 2, 9, 3, 2, 0, 0, 7, 8, 6, 8, 1, 0, 2, 8, 0, 5, 1, 8, 1, 5, 8, 2, 2, 1, 6, 1, 7, 5, 8, 0, 8, 3, 0, 7, 1, 7, 9, 7, 5
Offset: 1

Author

Jwalin Bhatt, Jul 06 2025

Keywords

Comments

The geometric mean of the Poisson distribution with parameter value 1 (A385685) approaches this constant.

Examples

			1.4210379597319607153378144890592856953982...
		

Crossrefs

Programs

  • Mathematica
    N[Exp [Sum[Log[i]/Factorial[i], {i, 2, Infinity}] / (E-1) ], 120]
  • PARI
    prodinf(k=2, k^(1/k!))^(1/(exp(1)-1))

Formula

Equals exp((Sum_{k>=2} log(k)/k!)/(e-1)).
Equals (Product_{k>=2} k^(1/k!)) ^ (1/(e-1)).
From Vaclav Kotesovec, Jul 08 2025: (Start)
Equals exp(A306243/(exp(1) - 1)).
Equals A296301^(1/(exp(1) - 1)). (End)

A385685 Sequence where k is appended after every k! occurrences of 1, with multiple values following a 1 listed in order.

Original entry on oeis.org

1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 4, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3, 4, 1, 1, 2, 1, 1, 2, 1, 1, 2, 3
Offset: 0

Author

Jwalin Bhatt, Jul 06 2025

Keywords

Comments

The frequencies of the terms follow the Poisson distribution with parameter value 1.
The geometric mean approaches A385686 in the limit. In general, for parameter value p it approaches Product_{k>=2} k^(((p^(k-1))*((e-1)^(-p)))/k!).

Examples

			Every 1 is followed by a 1 because 1! = 1,
after every (2!=2) ones we see a 2,
after every (3!=6) ones we see a 3 and so on.
		

Crossrefs

Cf. A000142 (n!), A382093, A385686.

Programs

  • Mathematica
    A385685[n_] := Module[{N1 = 0,NR= 1, result = {},i=1}, While[Length[result] < n,N1++;AppendTo[result, 1]; Do[If[Mod[N1, Factorial[k]] == 0,    AppendTo[result, k];f[k == NR + 1, NR++]],{k, 2, NR + 1}];If[Length[result] > n, result = Take[result, n]]];result];A385685[92] (* James C. McMahon, Jul 11 2025 *)
  • Python
    from itertools import islice
    from math import factorial
    def poisson_distribution_generator():
        num_ones, num_reached = 0, 1
        while num_ones := num_ones+1:
            yield 1
            for num in range(2, num_reached+2):
                if num_ones % factorial(num) == 0:
                    yield num
                    num_reached += num == num_reached+1
    A385685 = list(islice(poisson_distribution_generator(), 120))

A385170 a(n) is the integer part of the reciprocal of the distance of x_n from its nearest integer, where x_n is the n-th extrema of gamma(x).

Original entry on oeis.org

1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
Offset: 0

Author

Jwalin Bhatt, Jun 20 2025

Keywords

Comments

For n>=1, the nearest integer is -n and x_n drifts slowly towards it so that a(n) is a slowly increasing function of n.
a(n) = k occurs for the first time at n = A374856(k).
a(n) approximately equals floor(Pi/arctan(Pi/log(n))).
The corresponding gamma function value y_n = gamma(x_n) decreases in absolute value and A377506 captures its reciprocal (with a round).

Examples

			For n=10, x_10 = -9.702672... (A256687) and its nearest integer is -10 which is distance d = -9.702672... - (-10) = 0.297... away and a(n) = floor(1/d) = 3.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[
    {bounds, gammaExtrema, fractionalPart, intReci},
    bounds = {-n - 1 + 1/(n + 3), -n - 0.5};
    gammaExtrema = x /. FindRoot[PolyGamma[0, x + 1] == 0, {x, Sequence @@ bounds}];
    gammaExtrema = -Abs[gammaExtrema];
    fractionalPart = Mod[gammaExtrema, 1];
    Floor[1 / fractionalPart]
    ]
  • Python
    from gmpy2 import mpq, get_context, digamma, sign, is_nan, RoundUp, RoundDown
    def apply_on_interval(func, interval):
        ctx.round = RoundUp
        rounded_up = func(interval[0])
        ctx.round = RoundDown
        rounded_down = func(interval[1])
        return rounded_down, rounded_up
    def digamma_sign_near_int(i, f):
        while True:
            d, u = apply_on_interval(lambda x: digamma(i + 1/x), [f, f])
            sign_d = sign(d)
            if not(is_nan(d)) and not(is_nan(u)) and (sign_d == sign(u)):
                return sign_d
            ctx.precision += 1
    def generate_sequence(n):
        i, f, seq = -1, mpq('2'), [1]
        while len(seq) < n:
            if digamma_sign_near_int(i, f) != -1:
                f += 1
            seq.append(int(f)-1)
            i -= 1
        return seq
    ctx = get_context()
    ctx.precision = 2
    A385170 = generate_sequence(101)

A383855 The n-th term of the sequence is k after every k*(k+1)/2 occurrences of 1, with multiple values following a 1 listed in order.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1, 1, 2, 1, 4, 1, 1, 2, 3, 1, 1, 1, 2, 5, 1, 1, 1, 2, 3, 1, 1, 4, 1, 2, 6, 1, 1, 1, 2, 3, 1, 1, 1, 2, 1, 7, 1, 1, 2, 3, 4, 5, 1, 1, 1, 2, 1, 1, 1, 2, 3, 8, 1, 1, 1, 2, 1, 4, 1, 1, 2, 3, 6, 1, 1, 1, 2, 5, 9, 1, 1, 1, 2, 3, 1, 1, 4, 1, 2, 1, 1, 1, 2, 3, 1, 10
Offset: 1

Author

Jwalin Bhatt, May 12 2025

Keywords

Comments

The frequencies of the terms follow the Yule-Simon distribution with parameter value 1. The geometric mean approaches A245254 in the limit.

Examples

			After every ((2*3)/2=3) ones we see a 2,
after every ((3*4)/2=6) ones we see a 3,
after every ((4*5)/2=10) ones we see a 4 and so on.
		

Crossrefs

Programs

  • Python
    from itertools import islice
    def beta_distribution_generator():
        num_ones, num_reached = 0, 1
        while num_ones := num_ones+1:
            yield 1
            for num in range(2, num_reached+2):
                if num_ones % (num*(num+1)//2) == 0:
                    yield num
                    num_reached += num == num_reached+1
    A383855 = list(islice(beta_distribution_generator(), 120))

A383899 A sequence constructed by greedily sampling the Yule-Simon distribution for parameter value 1, to minimize discrepancy selecting the smallest value in case of ties.

Original entry on oeis.org

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

Author

Jwalin Bhatt, May 14 2025

Keywords

Comments

The geometric mean approaches A245254 in the limit.
The probability mass function of the Yule-Simon distribution with parameter 1 is given by p(k) = 1/(k*(k+1)) for k >= 1.

Examples

			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(k) 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.5       |     0.166     |     0.083     |   1    |
| 2 |     0         |     0.333     |     0.166     |   2    |
| 3 |     0.5       |    -0.5       |     0.25      |   1    |
| 4 |     0         |    -0.333     |     0.333     |   3    |
| 5 |     0.5       |    -0.166     |    -0.583     |   1    |
		

Crossrefs

Programs

  • Mathematica
    probCountDiff[j_, k_, count_]:=k/(j*(j+1))-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]
    A383899=samplePDF[120]