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

A055120 Digital complement of n (replace each nonzero digit d with 10-d).

Original entry on oeis.org

0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 90, 99, 98, 97, 96, 95, 94, 93, 92, 91, 80, 89, 88, 87, 86, 85, 84, 83, 82, 81, 70, 79, 78, 77, 76, 75, 74, 73, 72, 71, 60, 69, 68, 67, 66, 65, 64, 63, 62, 61, 50, 59, 58, 57, 56, 55, 54, 53, 52, 51, 40, 49, 48, 47, 46, 45, 44, 43, 42, 41, 30, 39
Offset: 0

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Comments

a(n) = -n in carryless arithmetic mod 10 - that is, n + a(n) = 0 (cf. A169894). - N. J. A. Sloane, Aug 03 2010

Examples

			a(11) = 99 because 1 + 9 = 0 mod 10 for each digit.
a(20) = 80 because 2 + 8 = 0 mod 10 and 0 + 0 = 0 mod 10.
		

Crossrefs

Column k=10 of A248813.

Programs

  • Haskell
    a055120 = foldl f 0 . reverse . unfoldr g where
       f v d = if d == 0 then 10 * v else 10 * v + 10 - d
       g x = if x == 0 then Nothing else Just $ swap $ divMod x 10
    -- Reinhard Zumkeller, Oct 04 2011
    
  • Maple
    f:=proc(n) local t0,t1,i;
    t0:=0; t1:=convert(n,base,10);
    for i from 1 to nops(t1) do
    if t1[i]>0 then t0:=t0+(10-t1[i])*10^(i-1); fi;
    od:
    RETURN(t0);
    end;
    # N. J. A. Sloane, Jan 21 2011
  • Mathematica
    a[n_] := FromDigits[ IntegerDigits[n] /. d_?Positive -> 10-d]; Table[a[n], {n, 0, 100}](* Jean-François Alcover, Nov 28 2011 *)
  • PARI
    a(n)=fromdigits(apply(d->if(d,10-d,0),digits(n))) \\ Charles R Greathouse IV, Feb 08 2017
    
  • Python
    def A055120(n): return int(''.join(str(10-int(d)) if d != '0' else d for d in str(n))) # Chai Wah Wu, Apr 03 2021

Formula

From Robert Israel, Sep 04 2017: (Start)
a(10*n) = 10*a(n).
a(10*n+j) = 10*a(n) + 10 - j for 1 <= j <= 9.
G.f. g(x) satisfies g(x) = 10*(1+x+x^2+...+x^9)*g(x^10) + (9*x+8*x^2+7*x^3+6*x^4+5*x^5+4*x^6+3*x^7+2*x^8+x^9)/(1-x^10).
(End)

A368310 Symmetric array read by antidiagonals: A(n,k) is the number of carryless sums i + j with abs(i) <= n and abs(j) <= k.

Original entry on oeis.org

1, 2, 2, 3, 4, 3, 4, 6, 6, 4, 5, 8, 9, 8, 5, 6, 10, 12, 12, 10, 6, 7, 12, 15, 16, 15, 12, 7, 8, 14, 18, 20, 20, 18, 14, 8, 9, 16, 21, 24, 25, 24, 21, 16, 9, 10, 18, 24, 28, 30, 30, 28, 24, 18, 10, 11, 19, 26, 31, 34, 35, 34, 31, 26, 19, 11, 12, 21, 27, 33, 37, 39, 39, 37, 33, 27, 21, 12
Offset: 0

Views

Author

Stefano Spezia, Dec 21 2023

Keywords

Comments

A(n,k) differs from A003991(n+1,k+1) starting at the second term of the 11th antidiagonal: A(9,1) = 19 <> A003991(10,2) = 20.

Examples

			Array begins:
   1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, ...
   2,  4,  6,  8, 10, 12, 14, 16, 18, 19, 21, ...
   3,  6,  9, 12, 15, 18, 21, 24, 26, 27, 30, ...
   4,  8, 12, 16, 20, 24, 28, 31, 33, 34, 38, ...
   5, 10, 15, 20, 25, 30, 34, 37, 39, 40, 45, ...
   6, 12, 18, 24, 30, 35, 39, 42, 44, 45, 51, ...
   7, 14, 21, 28, 34, 39, 43, 46, 48, 49, 56, ...
   8, 16, 24, 31, 37, 42, 46, 49, 51, 52, 60, ...
   9, 18, 26, 33, 39, 44, 48, 51, 53, 54, 63, ...
  10, 19, 27, 34, 40, 45, 49, 52, 54, 55, 65, ...
  11, 21, 30, 38, 45, 51, 56, 60, 63, 65, 76, ...
  ...
A(6,5) = A003991(7,6) - A368311(6,5) = (6 + 1)*(5 + 1) - 3 = 39 since there are three sums with carries having addends almost equal to 6 and 5, respectively: 5 + 5 = 10, 6 + 4 = 10, and 6 + 5 = 11.
		

Crossrefs

Cf. A003056, A003991, A059692, A169894, A368311 (sums with carries).

Programs

  • Mathematica
    len[num_]:=Length[IntegerDigits[num]]; digit[num_, d_]:=Part[IntegerDigits[num], d];  B[i_, j_] := Reverse[CoefficientList[Sum[digit[i, c]*x^(len[i]-c), {c, len[i]}] + Sum[digit[j, r]*x^(len[j]-r), {r, len[j]}], x]]; A[n_,k_] := Sum[Sum[Boole[Length[Select[B[i,j], #<10 &]] == IntegerLength[Max[i,j]]],{i,0,n}],{j,0,k}]; Table[A[i - j, j], {i, 0, 11}, {j, 0, i}]//Flatten

Formula

A(n,k) = A003991(n+1,k+1) for n + k < 10.
A(n,0) = A(0,n) = n + 1.
A(n,k) = A003991(n+1,k+1) - A368311(n,k).

A368311 Symmetric array read by antidiagonals: A(n,k) is the number of sums with carries i + j with abs(i) <= n and abs(j) <= k.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0, 0, 1, 3, 6, 6, 6, 6, 6, 6, 6, 3, 1, 0, 0, 1, 3, 6, 10, 10, 10, 10, 10, 10, 6, 3, 1, 0
Offset: 0

Views

Author

Stefano Spezia, Dec 21 2023

Keywords

Examples

			Array begins:
  0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0, ...
  0, 0, 0, 0,  0,  0,  0,  0,  0,  1,  1,  1, ...
  0, 0, 0, 0,  0,  0,  0,  0,  1,  3,  3,  3, ...
  0, 0, 0, 0,  0,  0,  0,  1,  3,  6,  6,  6, ...
  0, 0, 0, 0,  0,  0,  1,  3,  6, 10, 10, 10, ...
  0, 0, 0, 0,  0,  1,  3,  6, 10, 15, 15, 15, ...
  0, 0, 0, 0,  1,  3,  6, 10, 15, 21, 21, 21, ...
  0, 0, 0, 1,  3,  6, 10, 15, 21, 28, 28, 28, ...
  0, 0, 1, 3,  6, 10, 15, 21, 28, 36, 36, 36, ...
  0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 45, 46, ...
  0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 45, 46, ...
  0, 1, 3, 6, 10, 15, 21, 28, 36, 46, 46, 47, ...
  ...
A(6,5) = 3 since there are three sums with carries having addends almost equal to 6 and 5, respectively: 5 + 5 = 10, 6 + 4 = 10, and 6 + 5 = 11.
		

Crossrefs

Cf. A003056, A003991, A059692, A169894, A368310 (carryless sums).

Programs

  • Mathematica
    len[num_]:=Length[IntegerDigits[num]]; digit[num_, d_] := Part[IntegerDigits[num], d];  B[i_, j_] := Reverse[CoefficientList[Sum[digit[i, c]*x^(len[i]-c), {c, len[i]}]+Sum[digit[j, r]*x^(len[j]-r), {r, len[j]}], x]]; F[n_,k_] := Sum[Sum[Boole[Length[Select[B[i,j], #<10 &]] == IntegerLength[Max[i,j]]],{i,0,n}],{j,0,k}]; A[i_,j_]:=(i+1)(j+1)-F[i,j]; Table[A[i - j, j], {i, 0, 13}, {j, 0, i}]//Flatten

Formula

A(n,0) = A(0,n) = 0.
A(n,k) = A003991(n+1,k+1) - A368310(n,k).
Showing 1-3 of 3 results.