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-10 of 27 results. Next

A061470 First (leftmost) digit - second digit + third digit - fourth digit .... = 1.

Original entry on oeis.org

1, 10, 21, 32, 43, 54, 65, 76, 87, 98, 100, 111, 122, 133, 144, 155, 166, 177, 188, 199, 210, 221, 232, 243, 254, 265, 276, 287, 298, 320, 331, 342, 353, 364, 375, 386, 397, 430, 441, 452, 463, 474, 485, 496, 540, 551, 562, 573, 584, 595, 650, 661, 672, 683
Offset: 1

Views

Author

Amarnath Murthy, May 05 2001

Keywords

Examples

			221 is in the sequence since 2-2+1 = 1.
		

Crossrefs

Programs

  • Haskell
    a061470 n = a061470_list !! (n-1)
    a061470_list = filter ((== 1) . a225693) [0..]
    -- Reinhard Zumkeller, Aug 08 2014
  • Mathematica
    d[n_]:=IntegerDigits[n]; a[n_]:=Differences[Reverse[Total/@{Take[d[n],{1,-1,2}],Take[d[n],{2,-1,2}]}]]; Select[Range[690],a[#]=={1} &] (* Jayanta Basu, May 18 2013 *)
    Select[Range[1000],Total[Times@@@Partition[Riffle[IntegerDigits[#],{1,-1},{2,-1,2}],2]]==1&] (* Harvey P. Dale, May 24 2021 *)

Formula

A225693(a(n)) = 1. - Reinhard Zumkeller, Aug 08 2014

Extensions

More terms from Robert G. Wilson v, May 10 2001 and from Larry Reeves (larryr(AT)acm.org), May 14 2001

A061870 Numbers such that |first digit - second digit + third digit - fourth digit ...| = 1.

Original entry on oeis.org

1, 10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98, 100, 111, 120, 122, 131, 133, 142, 144, 153, 155, 164, 166, 175, 177, 186, 188, 197, 199, 210, 221, 230, 232, 241, 243, 252, 254, 263, 265, 274, 276, 285, 287, 296, 298, 320, 331, 340, 342
Offset: 1

Views

Author

Robert G. Wilson v, May 10 2001

Keywords

Comments

Multiples of 11 plus or minus 1. If 11k+1 is a perfect square (see A219257) then a(n) is the square root of 11k+1. [Gary Detlefs, Feb 22 2010]

Examples

			120 is in the sequence since |1-2+0| = 1.
		

Crossrefs

Programs

  • Mathematica
    fQ[n_] := Abs[Plus @@ (((-1)^Range[Floor[Log[10, n] + 1]])*IntegerDigits@n)] == 1; Select[ Range@342, fQ@# &]
  • PARI
    altsum(v)=sum(i=1,#v,v[i]*(-1)^i)
    is(n)=abs(altsum(digits(n)))==1 \\ Charles R Greathouse IV, May 21 2014
    
  • Python
    def ok(n): return abs(sum(int(di)*(-1)**i for i, di in enumerate(str(n)))) == 1
    print([k for k in range(343) if ok(k)]) # Michael S. Branicky, Jan 26 2023

A060978 |First digit - second digit + third digit - fourth digit ...| = 10.

Original entry on oeis.org

109, 208, 219, 307, 318, 329, 406, 417, 428, 439, 505, 516, 527, 538, 549, 604, 615, 626, 637, 648, 659, 703, 714, 725, 736, 747, 758, 769, 802, 813, 824, 835, 846, 857, 868, 879, 901, 912, 923, 934, 945, 956, 967, 978, 989, 1090, 1209, 1308, 1319, 1407
Offset: 1

Views

Author

Robert G. Wilson v, May 10 2001

Keywords

Crossrefs

Programs

  • Mathematica
    Do[ a = IntegerDigits[ n ]; l = Length[ a ]; e = o = {}; Do[ o = Append[ o, a[ [ 2k - 1 ] ] ], {k, 1, l/2 + .5} ]; Do[ e = Append[ e, a[ [ 2k ] ] ], {k, 1, l/2} ]; If[ Abs[ Apply[ Plus, o ] - Apply[ Plus, e ] ] == 10, Print[ n ] ], {n, 1, 2000} ]
    Select[Range[1500],Abs[Total[Times@@@Partition[Riffle[IntegerDigits[#],{1,-1},{2,-1,2}],2]]]==10&] (* Harvey P. Dale, Apr 13 2020 *)

A060980 |First digit - second digit + third digit - fourth digit ...| = 12.

Original entry on oeis.org

309, 408, 419, 507, 518, 529, 606, 617, 628, 639, 705, 716, 727, 738, 749, 804, 815, 826, 837, 848, 859, 903, 914, 925, 936, 947, 958, 969, 1409, 1508, 1519, 1607, 1618, 1629, 1706, 1717, 1728, 1739, 1805, 1816, 1827, 1838, 1849, 1904, 1915, 1926, 1937
Offset: 1

Views

Author

Robert G. Wilson v, May 10 2001

Keywords

Crossrefs

Programs

  • Mathematica
    Do[ a = IntegerDigits[ n ]; l = Length[ a ]; e = o = {}; Do[ o = Append[ o, a[ [ 2k - 1 ] ] ], {k, 1, l/2 + .5} ]; Do[ e = Append[ e, a[ [ 2k ] ] ], {k, 1, l/2} ]; If[ Abs[ Apply[ Plus, o ] - Apply[ Plus, e ] ] == 12, Print[ n ] ], {n, 1, 2000} ]
    Select[Range[2000],Abs[Total[Times@@@Partition[Riffle[IntegerDigits[#],{1,-1},{2,-1,2}],2]]]==12&] (* Harvey P. Dale, Sep 12 2017 *)

A060982 a(n) = Smallest nontrivial number k > 9 such that |first (leftmost) decimal digit of k - second digit + third digit - fourth digit ...| = n.

Original entry on oeis.org

11, 10, 13, 14, 15, 16, 17, 18, 19, 90, 109, 209, 309, 409, 509, 609, 709, 809, 909, 10909, 20909, 30909, 40909, 50909, 60909, 70909, 80909, 90909, 1090909, 2090909, 3090909, 4090909, 5090909, 6090909, 7090909, 8090909, 9090909, 109090909, 209090909, 309090909
Offset: 0

Views

Author

Robert G. Wilson v, May 10 2001

Keywords

Comments

Starting with 109, this sequence has the same terms as A061479 and A061882. - Georg Fischer, May 24 2022

Crossrefs

Programs

  • Mathematica
    m = 2; Do[ While[ a = IntegerDigits[ m ]; l = Length[ a ]; e = o = {}; Do[ o = Append[ o, a[ [ 2k - 1 ] ] ], {k, 1, l/2 + .5} ]; Do[ e = Append[ e, a[ [ 2k ] ] ], {k, 1, l/2} ]; Abs[ Apply[ Plus, o ] - Apply[ Plus, e ] ] != n, m++ ]; Print[ m ], {n, 1, 50} ]
  • Python
    def f(m): return abs(sum((-1)**i*int(d) for i, d in enumerate(str(m))))
    def a(n):
        m = 10
        while f(m) != n: m += 1
        return m
    print([a(n) for n in range(28)]) # Michael S. Branicky, Nov 10 2021
    
  • Python
    # faster version based on formula
    def a(n):
        if n < 10: return [11, 10, 13, 14, 15, 16, 17, 18, 19, 90][n]
        q, r = divmod(n, 9)
        return int(str(r if r else 9) + "09"*(q if r else q-1))
    print([a(n) for n in range(40)]) # Michael S. Branicky, Nov 10 2021

Formula

For n > 8, if r = 0, a(n) = 90..90, else a(n) = r09..09, where r = n mod 9 and 90 and 09, resp., occur ceiling(n/9) times. - Michael S. Branicky, Nov 10 2021

Extensions

a(39) and beyond from Michael S. Branicky, Nov 10 2021
Definition amended by Georg Fischer, May 24 2022

A061882 a(n) = Smallest nontrivial number k > 9 such that first (leftmost) digit - second digit + third digit - fourth digit ... of k = n.

Original entry on oeis.org

11, 10, 20, 30, 40, 50, 60, 70, 80, 90, 109, 209, 309, 409, 509, 609, 709, 809, 909, 10909, 20909, 30909, 40909, 50909, 60909, 70909, 80909, 90909, 1090909, 2090909, 3090909, 4090909, 5090909, 6090909, 7090909, 8090909, 9090909, 109090909
Offset: 0

Views

Author

Larry Reeves (larryr(AT)acm.org), May 15 2001

Keywords

Comments

Starting with 109, this sequence has the same terms as A060982 and A061479. - Georg Fischer, May 24 2022

Crossrefs

Programs

  • PARI
    a(n) = my(k=1,d=digits(k)); while (sum(k=1, #d, (-1)^(k+1)*d[k]) != n, k++; d=digits(k)); k; \\ Michel Marcus, May 24 2022

Extensions

Definition amended by Georg Fischer, May 24 2022

A225693 Alternating sum of digits of n.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, May 27 2013

Keywords

Comments

A number n is divisible by 11 if and only if a(n) is divisible by 11. For generalizations see Sharpe and Webster, or the links below.
The primes p for which the absolute value of the alternating sum of digits of p is also a prime begin: 2, 3, 5, 7, 13, 29, 31, 41, 47, 53, 61, 79, 83, 97, 101, 113, 137, 139, 151. - Jonathan Vos Post, May 27 2013
The above prime sequence is A115261. - Jens Kruse Andersen, Jul 13 2014
Digital sum with alternating signs starting with a positive sign for the most significant digit. - Hieronymus Fischer, Mar 23 2014

Crossrefs

A055017 is closely related (but less natural).
Cf. A061479.
Cf. A004086.
Indices of 0..3: A135499, A061470, A061471, A061472.

Programs

  • Haskell
    a225693 = f 1 0 where
       f _ a 0 = a
       f s a x = f (negate s) (s * a + d) x' where (x', d) = divMod x 10
    -- Reinhard Zumkeller, May 11 2015, Aug 08 2014
    
  • Maple
    A225693 :=proc(n) local t1,i;
    t1:=convert(n,base,10);
    add((-1)^(i+nops(t1))*t1[i],i=1..nops(t1));
    end;
    [seq(A225693(n),n=0..120)];
  • Mathematica
    Table[Total[Times@@@Partition[Riffle[IntegerDigits[n],{1,-1},{2,-1,2}],2]],{n,0,90}] (* Harvey P. Dale, Nov 27 2015 *)
  • PARI
    a(n) = my(d=digits(n)); sum(k=1, #d, (-1)^(k+1)*d[k]); \\ Michel Marcus, Jul 15 2022
  • Python
    def a(n): return sum(int(d)*(-1)**i for i, d in enumerate(str(n)))
    print([a(n) for n in range(87)]) # Michael S. Branicky, Jul 14 2022
    
  • Smalltalk
    "Version for general bases"
    "Set base = 10 for this sequence"
    altDigitalSumLeft: base
    base > 1 ifTrue:  [m:= self integerFloorLog: base]
             ifFalse: [^self \\ 2].
    p:=1.
    s:=0.
    1 to: m by: 2 do: [ :k |
        p := p*base.
        s := s - (self // p) .
        p := p*base.
        s := s + (self // p) ].
    ^(self + ((base + 1)*s)) * (m alternate)
    "Version for base 10 using altDigitalSumRight from A055017"
    A225693
    ^(self A004086) altDigitalSumLeft: 10
    [by Hieronymus Fischer, Mar 23 2014]
    

Formula

If n has decimal expansion abc..xyz with least significant digit z, a(n) = a - b + c - d + ...
From Hieronymus Fischer, Mar 23 2014: (Start)
Formulas for general bases b > 1 (b = 10 for this sequence). Always m := floor(log_b(n)).
a(n) = Sum_{k>=0} (-1)^k*(floor(n*b^(k-m)) mod b). The sum is finite with floor(log_b(n)) as the highest index.
a(n) = (-1)^m*n - (b+1)*Sum_{k=1..m} (-1)^k*floor(n*b^(k-m-1)).
a(n) = (-1)^m*(n + (b+1)*Sum_{k>=1} (-1)^k*floor(n/b^k)).
a(n) = -(-1)^(m-k)*a(n mod b^k) + a(floor(n/b^k)), for 0 <= k <= m+1.
a(n) = (-1)^m*a(n mod b) + a(floor(n/b)).
a(n) = -(-1)^m*a(n mod b^2) + a(floor(n/b^2)).
a(n) = (-1)^m*A055017(n).
a(n) = A055017(A004086(n)).
a(A004086(A004086(n))) = a(n).
(End)
a(A135499(n)) = 0; a(A061470(n)) = 1. - Reinhard Zumkeller, Aug 08 2014
a(A061471(n)) = 2; a(A061472(n)) = 3. - Bernard Schott, Jul 14 2022

Extensions

Comment corrected by Jens Kruse Andersen, Jul 13 2014

A060979 |First digit - second digit + third digit - fourth digit ...| = 11.

Original entry on oeis.org

209, 308, 319, 407, 418, 429, 506, 517, 528, 539, 605, 616, 627, 638, 649, 704, 715, 726, 737, 748, 759, 803, 814, 825, 836, 847, 858, 869, 902, 913, 924, 935, 946, 957, 968, 979, 1309, 1408, 1419, 1507, 1518, 1529, 1606, 1617, 1628, 1639, 1705, 1716
Offset: 1

Views

Author

Robert G. Wilson v, May 10 2001

Keywords

Comments

Note that all terms are divisible by eleven.

Crossrefs

Programs

  • Haskell
    a060979 n = a060979_list !! (n-1)
    a060979_list = filter (\x -> let digs = map (read . return) $ show x in
                                 evens digs /= odds digs) [11, 22 ..]
       where evens [] = 0; evens [x] = x; evens (x:_:xs) = x + evens xs
             odds [] = 0; odds [x] = 0; odds (_:x:xs) = x + odds xs
    -- Reinhard Zumkeller, Jul 05 2014
  • Maple
    filter:= proc(n) local L,i;
      L:= convert(n,base,10);
      abs(add(L[i]*(-1)^i,i=1..nops(L))) = 11
    end proc:
    select(filter, [$1..1000] *~ 11); # Robert Israel, Jun 02 2023
  • Mathematica
    Do[ a = IntegerDigits[ n ]; l = Length[ a ]; e = o = {}; Do[ o = Append[ o, a[ [ 2k - 1 ] ] ], {k, 1, l/2 + .5} ]; Do[ e = Append[ e, a[ [ 2k ] ] ], {k, 1, l/2} ]; If[ Abs[ Apply[ Plus, o ] - Apply[ Plus, e ] ] == 11, Print[ n ] ], {n, 1, 2000} ]
    d11Q[n_]:=Module[{idn=IntegerDigits[n]},Abs[Total[Table[(-1)^(i+1) idn[[i]],{i,Length[idn]}]]]==11]; Select[Range[1800],d11Q] (* Harvey P. Dale, Aug 26 2012 *)

Extensions

Erroneous comment deleted by Robert Israel, Jun 02 2023

A061478 First (leftmost) digit - second digit + third digit - fourth digit .... = 9.

Original entry on oeis.org

9, 90, 108, 119, 207, 218, 229, 306, 317, 328, 339, 405, 416, 427, 438, 449, 504, 515, 526, 537, 548, 559, 603, 614, 625, 636, 647, 658, 669, 702, 713, 724, 735, 746, 757, 768, 779, 801, 812, 823, 834, 845, 856, 867, 878, 889, 900, 911, 922, 933, 944, 955
Offset: 1

Views

Author

Amarnath Murthy, May 05 2001

Keywords

Crossrefs

Programs

  • Mathematica
    Select[Range[1000],Total[Times@@@Partition[Riffle[IntegerDigits[#],{1,-1},{2,-1,2}],2]]==9&] (* Harvey P. Dale, Jul 16 2017 *)

Extensions

More terms from Robert G. Wilson v, May 10 2001 and from Larry Reeves (larryr(AT)acm.org), May 15 2001

A061471 First (leftmost) digit - second digit + third digit - fourth digit .... = 2.

Original entry on oeis.org

2, 20, 31, 42, 53, 64, 75, 86, 97, 101, 112, 123, 134, 145, 156, 167, 178, 189, 200, 211, 222, 233, 244, 255, 266, 277, 288, 299, 310, 321, 332, 343, 354, 365, 376, 387, 398, 420, 431, 442, 453, 464, 475, 486, 497, 530, 541, 552, 563, 574, 585, 596, 640, 651
Offset: 1

Views

Author

Amarnath Murthy, May 05 2001

Keywords

Comments

a(n) == 9*(-1)^d (mod 11) if a(n) has d digits. - Robert Israel, Aug 05 2020

Crossrefs

Programs

  • Maple
    filter:= proc(n) local d,L,j;
      L:= convert(n,base,10);
      d:= nops(L);
      add(L[j]*(-1)^(d-j),j=1..d)=2
    end proc:
    select(filter, [$1..1000]); # Robert Israel, Aug 05 2020
  • Mathematica
    okQ[n_] := With[{id = IntegerDigits[n]}, id.Array[2 Mod[#, 2] - 1&, Length[id]] == 2]; Select[Range[1000], okQ] (* Jean-François Alcover, Nov 17 2016 *)
    Select[Range[700],Total[Times@@@Partition[Riffle[IntegerDigits[#],{1,-1},{2,-1,2}],2]] == 2&] (* Harvey P. Dale, Mar 01 2023 *)

Extensions

More terms from Robert G. Wilson v, May 10 2001 and from Larry Reeves (larryr(AT)acm.org), May 14 2001
Showing 1-10 of 27 results. Next