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-4 of 4 results.

A329794 a(n) is the smallest positive k such that box(k,n) is a positive square, where box(k,n) is Eric Angelini's mapping defined in the Comments.

Original entry on oeis.org

2, 1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 5, 6, 7, 8, 9, 21, 1, 2, 3, 4, 6, 7, 8, 9, 19, 10, 11, 1, 2, 3, 9, 17, 18, 19, 29, 20, 10, 11, 12, 13, 19, 27, 28, 29, 39, 30, 20, 21, 22, 10, 4, 5, 6, 7, 8, 1
Offset: 1

Views

Author

N. J. A. Sloane, Dec 07 2019, based on a posting by Eric Angelini to the Sequence Fans Mailing List, Dec 07 2019. (Thanks to Rémy Sigrist for correcting the definition.)

Keywords

Comments

Eric Angelini's "box" map box(i,j) is defined as follows (see A330240). Write i, j in base 10 aligned to the right, say
i = bcd...ef
j = .gh...pq
Then the decimal expansion of box(i,j) is |b-0|, |c-g|, |d-h|, ..., |e-p|, |f-q|.
For example, box(12345,909) = 12644.

Examples

			For n = 1 the smallest k producing a square is 2 (as box(1,2) = 1, this 1 being the square of 1);
For n = 2 the smallest k producing a square is 1 (as box(2,1) = 1, this 1 being the square of 1);
For n = 3 the smallest k producing a square is 2 (as box(3,2) = 1, this 1 being the square of 1);
For n = 5 the smallest k producing a square is 3 (as box(5,1) = 4, this 4 being the square of 2);
For n = 16 the smallest k producing a square is 12 (as box(16,12) = 4, this 4 being the square of 2).
		

Crossrefs

Programs

  • Mathematica
    BOX[a_,b_]:=FromDigits@Abs[Subtract@@PadLeft[IntegerDigits/@{a,b}]];Table[k=1;While[!IntegerQ[a=Sqrt@BOX[k,n]]||a==0,k++];k,{n,100}] (* Giorgos Kalogeropoulos, Aug 20 2021 *)
  • PARI
    box(x,y) = if (x==0 || y==0, x+y, 10*box(x\10,y\10) + abs((x%10) - (y%10)))
    a(n) = for (k=1, oo, my (b=box(n,k)); if (b && issquare(b), return (b))) \\ Rémy Sigrist, Dec 07 2019
    
  • PARI
    A329794(n)={n>1&&for(k=1,n,issquare(A330240(n,k))&&return(k));2} \\ M. F. Hasler, Dec 07 2019
    
  • Python
    from sympy.ntheory.primetest import is_square
    def positive_square(n): return n > 0 and is_square(n)
    def box(i, j):
        si = str(i); sj = str(j); m = max(len(si), len(sj))
        si, sj = si.zfill(m), sj.zfill(m)
        return int("".join([str(abs(int(si[k])-int(sj[k]))) for k in range(m)]))
    def a(n):
        k = 1
        while not positive_square(box(k, n)): k += 1
        return k
    print([a(n) for n in range(1, 66)]) # Michael S. Branicky, Aug 20 2021

Formula

a(n) < n except for a(1) = 2. - M. F. Hasler, Dec 07 2019

A330237 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 >= 1.

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, 11, 7, 5, 3, 1, 1, 3, 5, 7, 11, 10, 12, 6, 4, 2, 0, 2, 4, 6, 12, 10, 11, 11, 13, 5, 3, 1, 1, 3, 5, 13, 11, 11, 12, 10, 12, 14, 4, 2, 0, 2, 4, 14, 12, 10, 12, 13, 11, 11, 13, 15, 3, 1, 1, 3, 15, 13, 11, 11, 13, 14, 12, 10, 12, 14, 16, 2, 0, 2, 16
Offset: 1

Views

Author

M. F. Hasler, Dec 06 2019

Keywords

Comments

A digit-wise analog of A049581.
The binary operator T: N x N -> N is commutative, therefore this table is symmetric and it does not matter in which direction the antidiagonals are read. It would also be sufficient to specify only the lower half of the square table: see A330238 for this variant. The operator is also defined for either argument equal to 0, which is the neutral element: T(x,0) = 0 for all x. Therefore we omit row & column 0 here, see A330240 for the table including these. Every element is its opposite or inverse, as shown by the zero diagonal T(x,x) = 0.

Examples

			The square array starts as follows:
   n | k=1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 ...
  ---+-----------------------------------------------------------
   1 |   0  1  2  3  4  5  6  7  8 11 10 11 12 13 14 15 16 17 ...
   2 |   1  0  1  2  3  4  5  6  7 12 11 10 11 12 13 14 15 16 ...
   3 |   2  1  0  1  2  3  4  5  6 13 12 11 10 11 12 13 14 15 ...
   4 |   3  2  1  0  1  2  3  4  5 14 13 12 11 10 11 12 13 14 ...
   5 |   4  3  2  1  0  1  2  3  4 15 14 13 12 11 10 11 12 13 ...
   6 |   5  4  3  2  1  0  1  2  3 16 15 14 13 12 11 10 11 12 ...
   7 |   6  5  4  3  2  1  0  1  2 17 16 15 14 13 12 11 10 11 ...
   8 |   7  6  5  4  3  2  1  0  1 18 17 16 15 14 13 12 11 10 ...
   9 |   8  7  6  5  4  3  2  1  0 19 18 17 16 15 14 13 12 11 ...
  10 |  11 12 13 14 15 16 17 18 19  0  1  2  3  4  5  6  7  8 ...
  11 |  10 11 12 13 14 15 16 17 18  1  0  1  2  3  4  5  6  7 ...
  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 > 10.
		

Crossrefs

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

Programs

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

A330238 Triangle T(n,k): concatenate the absolute differences of the digits of n and k (the smaller one padded with leading zeros); n >= k >= 1.

Original entry on oeis.org

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

Views

Author

M. F. Hasler, Dec 06 2019

Keywords

Comments

A digit-wise analog of A049581.
The binary operator T: N x N -> N is commutative, so we need only the lower half of the symmetric square table A330238 or A330240 (including n, k = 0). Also, 0 is the neutral element: T(x,0) = x for all x, therefore we omit row & column 0. The trivial diagonal T(x,x) = 0 could also be omitted but serves as an end-of-row marker and makes indexing simpler and more natural.

Examples

			The triangle starts as follows:
    n | k=1  2   3   4   5   6   7   8   9  10  11
   ---+-------------------------------------------
    1 |  0,
    2 |  1,  0,
    3 |  2,  1,  0,
    4 |  3,  2,  1,  0,
    5 |  4,  3,  2,  1,  0,
    6 |  5,  4,  3,  2,  1,  0,
    7 |  6,  5,  4,  3,  2,  1,  0,
    8 |  7,  6,  5,  4,  3,  2,  1,  0,
    9 |  8,  7,  6,  5,  4,  3,  2,  1,  0,
   10 | 11, 12, 13, 14, 15, 16, 17, 18, 19,  0,
   11 | 10, 11, 12, 13, 14, 15, 16, 17, 18,  1,  0,
   12 | 11, 10, 11, 12, 13, 14, 15, 16, 17,  2,  1,  0,
    (...)
		

Crossrefs

Cf. A330237 (same as a square array read by antidiagonals), A330240 (idem, including row & column 0), A049581 (T(n,k) = |n-k|).

Programs

  • PARI
    A330238(n,k)=fromdigits(digits(n)-abs(Vec(digits(k),-logint(n,10)-1))) \\ see A330240 for a more general function not limited to 1 <= k <= n

A338827 For any number with decimal representation (d(1), d(2), ..., d(k)), the decimal representation of a(n) is (abs(d(1)-d(k)), abs(d(2)-d(k-1)), ..., abs(d(k)-d(1))).

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 11, 22, 33, 44, 55, 66, 77, 88, 22, 11, 0, 11, 22, 33, 44, 55, 66, 77, 33, 22, 11, 0, 11, 22, 33, 44, 55, 66, 44, 33, 22, 11, 0, 11, 22, 33, 44, 55, 55, 44, 33, 22, 11, 0, 11, 22, 33, 44, 66, 55, 44, 33, 22, 11, 0, 11, 22
Offset: 0

Views

Author

Rémy Sigrist, Nov 11 2020

Keywords

Comments

Leading zeros are ignored.
All terms belong to A061917.

Examples

			For n = 1021:
- abs(1-1) = 0,
- abs(0-2) = 2,
- abs(2-0) = 2,
- abs(1-1) = 0,
- so a(1021) = 220.
		

Crossrefs

Cf. A002113, A004086, A056965, A061917, A175919 (binary analog), A330240, A338828 (ternary analog).

Programs

  • Maple
    a:= n-> (l-> (h-> add(h[j]*10^(j-1), j=1..nops(h)))([seq(
        abs(l[i]-l[-i]), i=1..nops(l))]))(convert(n, base, 10)):
    seq(a(n), n=0..70);  # Alois P. Heinz, Nov 12 2020
  • PARI
    a(n, base=10) = my (d=digits(n, base)); fromdigits(abs(d-Vecrev(d)), base)

Formula

a(n) = 0 iff n is a palindrome (A002113).
a(n) = A330240(n, A004086(n)).
Showing 1-4 of 4 results.