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.

A386883 Define a sequence of rationals by f(0) = 0, thereafter f(n) = f(n-1) - 1/n if that is >= 0, otherwise f(n) = f(n-1) + 1/n; a(n) corresponds to the number of addition steps minus the number of subtraction steps involved in calculating f(n).

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Aug 06 2025

Keywords

Comments

This sequence is unbounded below.
By contradiction:
- let M be the minimum value of the sequence and a(n) = M be the first occurrence of M in the sequence,
- as an addition step is always followed by a subtraction step, and the value M can only be followed by M+1, a(n+2*k) = M and a(n+2*k+1) = M+1 for any k >= 0,
- for any m >= n, f(m) = f(n) + Sum_{k = n+1..m} (-1)^(k-n-1) / k,
- as the alternating harmonic series converges to log(2), the sequence f will have a positive limit, say L > 0,
- hence for some m0 >= 0, f(m) > L/2 for any m >= m0,
- let k be such that n+2*k >= m0 and 1/(n+2*k+1) < L/2: f(n+2*k) > L/2, so f(n+2*k+1) = f(n+2*k) - 1/(n+2*k+1), and a(n+2*k+1) = a(n+2*k)-1 = M-1, a contradiction.

Examples

			Sequence begins:
  n   a(n)  f(n)-f(n-1)
  --  ----  -----------
   0     0  N/A
   1     1  +1
   2     0  -1/2
   3    -1  -1/3
   4     0  +1/4
   5    -1  -1/5
   6    -2  -1/6
   7    -1  +1/7
   8    -2  -1/8
   9    -1  +1/9
  10    -2  -1/10
  11    -1  +1/11
  12    -2  -1/12
  13    -3  -1/13
  14    -2  +1/14
  15    -3  -1/15
		

Crossrefs

Programs

  • Mathematica
    Module[{f = 0, a = 0}, Array[If[f >= 1/#, f -= 1/#; a--, f += 1/#; a++] &, 100]] (* Paolo Xausa, Aug 25 2025 *)
  • PARI
    { print1(0); f = 0; a = 0; for (n = 1, 65, if (f >= 1/n, f -= 1/n; a--, f += 1/n; a++); print1 (", "a);); }

Formula

a(n) = Sum_{k = 1..n} sign(A231692(n)/A231693(n) - A231692(n-1)/A231693(n-1)).