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.

Showing 1-9 of 9 results.

A133610 Partial sums of pyramidal sequence A053616.

Original entry on oeis.org

0, 0, 1, 1, 2, 3, 3, 4, 6, 7, 7, 8, 10, 12, 13, 13, 14, 16, 19, 21, 22, 22, 23, 25, 28, 31, 33, 34, 34, 35, 37, 40, 44, 47, 49, 50, 50, 51, 53, 56, 60, 64, 67, 69, 70, 70, 71, 73, 76, 80, 85, 89, 92, 94, 95, 95, 96, 98, 101, 105, 110, 115, 119, 122, 124, 125, 125, 126, 128, 131, 135
Offset: 0

Views

Author

Jonathan Vos Post, Dec 28 2007

Keywords

Crossrefs

Programs

  • Haskell
    a133610 n = a133610_list !! n
    a133610_list = scanl1 (+) a053616_list
    -- Reinhard Zumkeller, Jan 24 2014

Formula

a(n) = SUM[i=0..n] distance from i to nearest triangular number = SUM[i=0..n]MIN{|i - (k*(k+1)/2)|} = SUM[i=0..n] MIN{|A000217(i) - i|}.

Extensions

Data corrected by Reinhard Zumkeller, Jan 24 2014

A305258 List of y-coordinates of a point moving in a smooth counterclockwise spiral rotated by Pi/4.

Original entry on oeis.org

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

Views

Author

Hugo Pfoertner, May 29 2018

Keywords

Examples

			Sequence gives y-coordinate of the n-th point of the following spiral:
   d:
   4 |                  32  49
     |                 /   \   \
   3 |              33  18  31  48
     |             /   /   \   \   \
   2 |          34  19   8  17  30  47
     |         /   /   /   \   \   \   \
   1 |      35  20   9   2   7  16  29  46
     |     /   /   /   /   \   \   \   \   \
   0 |  36  21  10   3   0---1   6  15  28  45
     |     \   \   \   \       /   /   /   /
  -1 |      37  22  11   4---5  14  27  44
     |         \   \   \      /    /   /
  -2 |          38  23  12--13  26  43
     |             \   \       /   /
  -3 |              39  24--25  42
     |                 \       /
  -4 |                  40--41
       _______________________________________
  x:    -4  -3  -2  -1   0   1   2   3   4   5
		

Crossrefs

A010751 gives sequence of x-coordinates.
Cf. A053616.

Programs

  • PARI
    up=-1;print1(x=0,", ");for(stride=1,12,up=-up;x+=stride;y=x+stride+1;for(k=x,y-1,print1(up*min(k-x,y-k), ", "))) \\ Hugo Pfoertner, Jun 02 2018

Formula

a(n) = A053616(n)*sign(sin(Pi*(1+sqrt(1+8*n))/2)), so that abs(a(n)) = A053616(n).
a(n) = A010751(n-floor((1/2)*(sqrt(2n-1)+1))). - William McCarty, Jul 29 2021

A330240 Square array T(n,k): concatenate the absolute differences of the digits of n and k (the smaller one padded with leading zeros), read by antidiagonals, n, k >= 0.

Original entry on oeis.org

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

Views

Author

M. F. Hasler, Dec 06 2019

Keywords

Comments

A digit-wise analog of A049581. Referred to as "box" operation by Eric Angelini.
The binary operator T: N x N -> N is commutative, so this table is symmetric: it does not matter in which direction the antidiagonals are read, and it would be sufficient to specify only the lower half of the square table: see A330238 for this triangle. Zero is the neutral element: T(x,0) = x for all x. Any x is its own inverse or opposite x', as shown by the zero diagonal T(x,x) = 0.
A measure of non-associativity is the "commutator" ((x T y) T x') T y' = ((x T y) T x) T y which would be zero in the associative case, given that x = x' for all x. Here it turns out to be given by 2*A053616, read as a triangle, and rows extended quasi-periodically with period 10, see example.

Examples

			The square array starts as follows:
   n |k=0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 ...
  ---+-------------------------------------------------------------
   0 |  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 ...
   1 |  1  0  1  2  3  4  5  6  7  8 11 10 11 12 13 14 15 16 17 ...
   2 |  2  1  0  1  2  3  4  5  6  7 12 11 10 11 12 13 14 15 16 ...
   3 |  3  2  1  0  1  2  3  4  5  6 13 12 11 10 11 12 13 14 15 ...
   4 |  4  3  2  1  0  1  2  3  4  5 14 13 12 11 10 11 12 13 14 ...
   5 |  5  4  3  2  1  0  1  2  3  4 15 14 13 12 11 10 11 12 13 ...
   6 |  6  5  4  3  2  1  0  1  2  3 16 15 14 13 12 11 10 11 12 ...
   7 |  7  6  5  4  3  2  1  0  1  2 17 16 15 14 13 12 11 10 11 ...
   8 |  8  7  6  5  4  3  2  1  0  1 18 17 16 15 14 13 12 11 10 ...
   9 |  9  8  7  6  5  4  3  2  1  0 19 18 17 16 15 14 13 12 11 ...
  10 | 10 11 12 13 14 15 16 17 18 19  0  1  2  3  4  5  6  7  8 ...
  11 | 11 10 11 12 13 14 15 16 17 18  1  0  1  2  3  4  5  6  7 ...
  12 | 12 11 10 11 12 13 14 15 16 17  2  1  0  1  2  3  4  5  6 ...
   (...)
It differs from A049581 only if at least one index is > 9.
The table of commutators Comm(n,k) := T(T(T(n,k),n),k) reads as follows:
   n |k=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22...
  ---+---------------------------------------------------------------
   0 |  0 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0...
   1 |  0 0 2 2 2 2 2 2 2 2  0  0  2  2  2  2  2  2  2  2  0  0  2...
   2 |  0 0 0 2 4 4 4 4 4 4  0  0  0  2  4  4  4  4  4  4  0  0  0...
   3 |  0 0 0 0 2 4 6 6 6 6  0  0  0  0  2  4  6  6  6  6  0  0  0...
   4 |  0 0 0 0 0 2 4 6 8 8  0  0  0  0  0  2  4  6  8  8  0  0  0...
   5 |  0 0 0 0 0 0 2 4 6 8  0  0  0  0  0  0  2  4  6  8  0  0  0...
   6 |  0 0 0 0 0 0 0 2 4 6  0  0  0  0  0  0  0  2  4  6  0  0  0...
   7 |  0 0 0 0 0 0 0 0 2 4  0  0  0  0  0  0  0  0  2  4  0  0  0...
   8 |  0 0 0 0 0 0 0 0 0 2  0  0  0  0  0  0  0  0  0  2  0  0  0...
   9 |  0 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0...
  10 |  0 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0 20 20 20...
  11 |  0 0 2 2 2 2 2 2 2 2  0  0  2  2  2  2  2  2  2  2 20 20 22...
  12 |  0 0 0 2 4 4 4 4 4 4  0  0  0  2  4  4  4  4  4  4 20 20 20...
   (...)
Up to row & column 10, the columns are twice the sequence A053616 written as triangle. The first 10 X 10 block repeats horizontally and vertically. Further away from the origin, the elements of this block multiplied by corresponding powers of 10 are added to the corresponding 10 X 10 blocks: e.g., the block Comm(130..139,270..279) = Comm(0..9,0..9) + 260, where 260 = 100*Comm(1,2) + 10*Comm(3,7).
		

Crossrefs

Cf. A330238 (variant excluding row & column 0), A330237 (lower left triangle), A049581 (T(n,k) = |n-k|).

Programs

  • PARI
    A330240(a,b)=fromdigits(abs(Vec(digits(min(a,b)),if(a+b,-logint(a=max(a,b),10)-1))-digits(a)))

A354330 Distance from the sum of the first n positive triangular numbers to the nearest triangular number.

Original entry on oeis.org

0, 0, 1, 0, 1, 1, 1, 6, 0, 6, 10, 10, 13, 10, 1, 14, 4, 21, 12, 4, 0, 1, 8, 22, 28, 1, 36, 1, 35, 30, 10, 4, 11, 10, 0, 20, 51, 41, 10, 71, 4, 62, 41, 6, 45, 75, 91, 88, 97, 85, 55, 10, 51, 100, 10, 99, 20, 124, 29, 56, 130, 90, 48, 20, 7, 10, 30, 68, 125, 136
Offset: 0

Views

Author

Paolo Xausa, Jun 04 2022

Keywords

Comments

a(n) = 0 for n in {0, 1, 3, 8, 20, 34} = A224421.

Examples

			a(4) = 1 because the sum of the first 4 positive triangular numbers is 1 + 3 + 6 + 10 = 20, the nearest triangular number is 21 and 21 - 20 = 1.
		

Crossrefs

Programs

  • Mathematica
    nterms=100;Table[ts=n(n+1)(n+2)/3;t=Floor[Sqrt[ts]];Abs[t^2+t-ts]/2,{n,0,nterms-1}]
  • PARI
    a(n)=my(ts=n*(n+1)*(n+2)/3,t=sqrtint(ts));abs(t^2+t-ts)/2;
    vector(100,n,a(n-1)) \\ Paolo Xausa, Jul 06 2022
    
  • Python
    from math import isqrt
    def A354330(n): return abs((m:=isqrt(k:=n*(n*(n + 3) + 2)//3))*(m+1)-k)>>1 # Chai Wah Wu, Jul 15 2022

Formula

a(n) = A053616(A000292(n)).
a(n) = abs(A000292(n) - A354329(n)).

A296239 a(n) = distance from n to nearest Fibonacci number.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Dec 09 2017

Keywords

Comments

The Fibonacci numbers correspond to sequence A000045.
This sequence is analogous to:
- A051699 (distance to nearest prime),
- A053188 (distance to nearest square),
- A053646 (distance to nearest power of 2),
- A053615 (distance to nearest oblong number),
- A053616 (distance to nearest triangular number),
- A061670 (distance to nearest power),
- A074989 (distance to nearest cube),
- A081134 (distance to nearest power of 3),
The local maxima of the sequence correspond to positive terms of A004695.
a(n) = 0 iff n = A000045(k) for some k >= 0.
a(n) = 1 iff n = A061489(k) for some k > 4.
For any n >= 0, abs(a(n+1) - a(n)) <= 1.
For any n > 0, a(n) < n, and a^k(n) = 0 for some k > 0 (where a^k denotes the k-th iterate of a); k equals A105446(n) for n = 1..80 (and possibly more values).
a(n) > max(a(n-1), a(n+1)) iff n = A001076(k) for some k > 1.

Examples

			For n = 42:
- A000045(9) = 34 <= 42 <= 55 = A000045(10),
- a(42) = min(42 - 34, 55 - 42) = min(8, 13) = 8.
		

Crossrefs

Programs

  • Mathematica
    fibPi[n_] := 1 + Floor[ Log[ GoldenRatio, 1 + n*Sqrt@5]]; f[n_] := Block[{m = fibPi@ n}, Min[n - Fibonacci[m -1], Fibonacci[m] - n]]; Array[f, 81, 0] (* Robert G. Wilson v, Dec 11 2017 *)
    With[{nn=80,fibs=Fibonacci[Range[0,20]]},Table[Abs[n-Nearest[fibs,n]][[1]],{n,0,nn}]] (* Harvey P. Dale, Jul 02 2022 *)
  • PARI
    a(n) = for (i=1, oo, if (n<=fibonacci(i), return (min(n-fibonacci(i-1), fibonacci(i)-n))))

Formula

a(n) = abs(n - Fibonacci(floor(log(sqrt(20)*n)/log((1 + sqrt(5))/2)-1))). - Jon E. Schoenfield, Dec 14 2017

A238455 Difference between 4^n and the nearest triangular number.

Original entry on oeis.org

0, 1, 1, -2, 3, -11, 1, -87, -167, -306, -500, -552, 688, -3041, -579, 20854, 37075, 55618, 37108, -222296, -147729, 891994, 602155, -3523022, -2228805, 14811346, 11792251, -47737262, -1136517, 375078994, 741065851, 1445763154, 2746052116, 4910207464, 7492827856
Offset: 0

Views

Author

Alex Ratushnyak, Feb 26 2014

Keywords

Examples

			a(0) = 1 - 1 = 0.
a(1) = 4 - 3 = 1.
a(2) = 16 - 15 = 1.
a(3) = 64 - 66 = -2.
a(4) = 256 - 253 = 3.
		

Crossrefs

Absolute values give the other bisection of A233327.

Programs

  • Mathematica
    db4n[n_]:=Module[{c=4^n,tr,t1,t2,d1,d2},tr=Floor[(Sqrt[8c+1]-1)/2];t1= (tr (tr+1))/ 2;t2=((tr+1)(tr+2))/2;d1=c-t1;d2=c-t2;If[d1Harvey P. Dale, Jul 02 2019 *)
  • PARI
    a(n) = my(p=4^n, t=sqrtint(2*p)); (-t^2 - t + 2*p)/2; \\ Michel Marcus, Jun 16 2022
  • Python
    def isqrt(a):
        sr = 1 << (int.bit_length(int(a)) >> 1)
        while a < sr*sr:  sr>>=1
        b = sr>>1
        while b:
            s = sr + b
            if a >= s*s:  sr = s
            b>>=1
        return sr
    for n in range(77):
        nn = 4**n
        s = isqrt(2*nn)
        if s*(s+1)//2 > nn:  s-=1
        d1 = nn - s*(s+1)//2
        d2 = (s+1)*(s+2)//2 - nn
        if d2 < d1:  d1 = -d2
        print(str(d1), end=',')
    

Formula

a(n) = (1/2)*(-t^2 - t + 2*4^n), where t = floor(sqrt(2*4^n)) after formula in A053616. - Michel Marcus, Jun 16 2022

A354329 Triangular number nearest to the sum of the first n positive triangular numbers.

Original entry on oeis.org

0, 1, 3, 10, 21, 36, 55, 78, 120, 171, 210, 276, 351, 465, 561, 666, 820, 990, 1128, 1326, 1540, 1770, 2016, 2278, 2628, 2926, 3240, 3655, 4095, 4465, 4950, 5460, 5995, 6555, 7140, 7750, 8385, 9180, 9870, 10731, 11476, 12403, 13203, 14196, 15225, 16290, 17205
Offset: 0

Views

Author

Paolo Xausa, Jun 04 2022

Keywords

Examples

			a(4) = 21 because the sum of the first 4 positive triangular numbers is 1 + 3 + 6 + 10 = 20, and the nearest triangular number is 21.
		

Crossrefs

Programs

  • Mathematica
    nterms=100;Table[t=Floor[Sqrt[n(n+1)(n+2)/3]];(t^2+t)/2,{n,0,nterms-1}]
  • PARI
    a(n)=my(t=sqrtint(n*(n+1)*(n+2)/3));(t^2+t)/2;
    vector(100,n,a(n-1))
    
  • Python
    from math import isqrt
    def A354329(n): return (m:=isqrt(n*(n*(n + 3) + 2)//3))*(m+1)>>1 # Chai Wah Wu, Jul 15 2022

Formula

a(n) = (t^2+t)/2, where t = floor(sqrt(n*(n+1)*(n+2)/3)).

A309914 Distance from n to closest triangular number that is different from n.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 3, 1, 2, 1, 4, 1, 2, 2, 1, 5, 1, 2, 3, 2, 1, 6, 1, 2, 3, 3, 2, 1, 7, 1, 2, 3, 4, 3, 2, 1, 8, 1, 2, 3, 4, 4, 3, 2, 1, 9, 1, 2, 3, 4, 5, 4, 3, 2, 1, 10, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 12, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 13, 1, 2, 3, 4, 5, 6, 7, 6, 5
Offset: 0

Views

Author

Ilya Gutkovskiy, Aug 22 2019

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{k = 1}, While[! IntegerQ[Sqrt[8 (n + k) + 1]] && ! IntegerQ[Sqrt[8 (n - k) + 1]], k++]; k]; Table[a[n], {n, 0, 100}]

A337938 Irregular triangle read by rows: T(n, k) gives the primitive period of the sequence {k (Modd n)}_{k >= 0}, for n >= 1.

Original entry on oeis.org

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

Views

Author

Wolfdieter Lang, Oct 25 2020

Keywords

Comments

The length of row n is 1 for n = 1, 2 for n = 2, and 2*n for n >= 3.
The modified modular equivalence relation Modd n is defined, for integer k and positive integer n, by k (Modd n) = k (mod n) if floor(k/n) is even, and -k (mod n) if floor(k/n) is odd. The smallest nonnegative complete residue system modulo n, namely RS(n) = {0, 1, ..., n-1}, is used. See the W. Lang link, Definition 4, eq. (69), p. 25 - 26.
In order to have row length 2*n for all n >= 1 one could use for n = 1 and 2 the imprimitive periods 0, 0 and 0, 1, 0, 1, respectively.
The name Modd n derives from the fact that the multiplicative (but not additive ) group Modd n has the smallest positive reduced residue system with only odd numbers, named RRSodd(n), as elements (for n = 0 RRS(n) = {0}, but here it is taken as {1}). This group is isomorphic to the Galois group G(rho(n)) = Gal(Q(rho(n))/Q), with rho(n) = 2*cos(pi/n). See the W. Lang link.

Examples

			The irregular triangle begins:
n \ k 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ..
1:    0
2:    0 1
3:    0 1 2 0 2 1
4:    0 1 2 3 0 3 2 1
5:    0 1 2 3 4 0 4 3 2 1
6:    0 1 2 3 4 5 0 5 4 3  2  1
7:    0 1 2 3 4 5 6 0 6 5  4  3  2  1
8:    0 1 2 3 4 5 6 7 0 7  6  5  4  3  2  1
9:    0 1 2 3 4 5 6 7 8 0  8  7  6  5  4  3  2  1
10   :0 1 2 3 4 5 6 7 8 9  0  9  8  7  6  5  4  3  2  1
...
T(1, 0) = 0 because {k (Modd 1)}_{k >= 0} is the 0 sequence A000007:  0 (Modd 1) =  0 (mod 1) = 0, 1 (Modd 1) = -1 (mod 1) = 0,  2 (Modd 1) = 2 (mod 1) = 0, ... .
T(7, 6) = 6 because floor(6/7) = 0, which is even, hence 6 (Modd 7) = 6 (mod 7) = 6.
T(7, 8) = 6 because  floor(8/7) = 1, which is odd, hence  8 (Modd 7) = -8 (mod 7) = 6.
		

Crossrefs

Cf. Periodic sequences for n = 1, 2, ..., 7: A000007, A000035, A193680, A193682, A203571, A203572.
Cf. A002262 (for mod n), A053616 (as a triangle, for mod* n).

Formula

T(n,k) = k (Modd n), for n >= 1, and k = 0 for n = 1, k = 0, 1 for n = 2, and k = 0, 1, ..., 2*n - 1, for n >= 3. For k (Modd n) see the comment above.
Showing 1-9 of 9 results.