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.

A240857 Triangle read by rows: T(0,0) = 0; T(n+1,k) = T(n,k+1), 0 <= k < n; T(n+1,n) = T(n,0); T(n+1,n+1) = T(n,0)+1.

This page as a plain text file.
%I A240857 #16 Nov 12 2024 09:03:41
%S A240857 0,0,1,1,0,1,0,1,1,2,1,1,2,0,1,1,2,0,1,1,2,2,0,1,1,2,1,2,0,1,1,2,1,2,
%T A240857 2,3,1,1,2,1,2,2,3,0,1,1,2,1,2,2,3,0,1,1,2,2,1,2,2,3,0,1,1,2,1,2,1,2,
%U A240857 2,3,0,1,1,2,1,2,2,3,2,2,3,0,1,1,2,1
%N A240857 Triangle read by rows: T(0,0) = 0; T(n+1,k) = T(n,k+1), 0 <= k < n; T(n+1,n) = T(n,0); T(n+1,n+1) = T(n,0)+1.
%C A240857 Let h be the initial term of row n, to get row n+1, remove h and then append h and h+1.
%H A240857 Reinhard Zumkeller, <a href="/A240857/b240857.txt">Rows n = 0..125 of triangle, flattened</a>
%F A240857 T(n,k) = A048881(n+k), 0 <= k <= n.
%F A240857 For n > 0: T(n,A035327(n)) = 0.
%e A240857 .   0:                                 0
%e A240857 .   1:                               0   1
%e A240857 .   2:                             1   0   1
%e A240857 .   3:                           0   1   1   2
%e A240857 .   4:                         1   1   2   0   1
%e A240857 .   5:                       1   2   0   1   1   2
%e A240857 .   6:                     2   0   1   1   2   1   2
%e A240857 .   7:                   0   1   1   2   1   2   2   3
%e A240857 .   8:                 1   1   2   1   2   2   3   0   1
%e A240857 .   9:               1   2   1   2   2   3   0   1   1   2
%e A240857 .  10:             2   1   2   2   3   0   1   1   2   1   2
%e A240857 .  11:           1   2   2   3   0   1   1   2   1   2   2   3
%e A240857 .  12:         2   2   3   0   1   1   2   1   2   2   3   1   2
%e A240857 .  13:       2   3   0   1   1   2   1   2   2   3   1   2   2   3
%e A240857 .  14:     3   0   1   1   2   1   2   2   3   1   2   2   3   2   3
%e A240857 .  15:   0   1   1   2   1   2   2   3   1   2   2   3   2   3   3   4 .
%t A240857 T[n_, k_] := DigitCount[n + k + 1, 2, 1] - 1; Table[T[n, k], {n, 0, 12}, {k, 0, n}] // Flatten (* _Amiram Eldar_, Aug 01 2023 *)
%o A240857 (Haskell)
%o A240857 a240857 n k = a240857_tabl !! n !! k
%o A240857 a240857_row n = a240857_tabl !! n
%o A240857 a240857_tabl = iterate (\(x:xs) -> xs ++ [x, x + 1]) [0]
%o A240857 (Python)
%o A240857 from math import isqrt
%o A240857 def A240857(n): return (n-((r:=(m:=isqrt(k:=n+1<<1))+(k>m*(m+1)))*(r-3)>>1)).bit_count()-1 # _Chai Wah Wu_, Nov 11 2024
%Y A240857 Cf. A048881 (left edge), A000120 (right edge), A000788 (row sums), A000523 (row maxima), A240883 (central terms).
%Y A240857 Cf. A035327.
%K A240857 nonn,tabl
%O A240857 0,10
%A A240857 _Reinhard Zumkeller_, Apr 14 2014