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

A040115 Concatenate absolute values of differences between adjacent digits of n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Let the decimal expansion of n be abcd...efg, say. Then a(n) has decimal expansion |a-b| |b-c| |c-d| ... |e-f| |f-g|. Leading zeros in a(n) are omitted.
From M. F. Hasler, Nov 09 2019: (Start)
This sequence coincides with A080465 up to a(109) but is thereafter completely different.
Eric Angelini calls a(n) the "ghost" of the number n and considers iterations of n -> n +- a(n) depending on parity of a(n), cf. A329200 and A329201. (End)

Examples

			a(371) = 46, for example.
a(110) = 01 = 1, while A080465(110) = 10 - 1 = 9. - _M. F. Hasler_, Nov 09 2019
		

Crossrefs

Cf. A329200, A329201: iterations of n +- a(n).

Programs

  • Mathematica
    Table[FromDigits[Abs[Differences[IntegerDigits[n]]]],{n,110}] (* Harvey P. Dale, Dec 16 2021 *)
  • PARI
    apply( A040115(n)=fromdigits(abs((n=digits(n+!n))[^-1]-n[^1])), [10..199]) \\ Works for all n >= 0. - M. F. Hasler, Nov 09 2019

Formula

a(n) = 0 iff n is a repdigit >= 11 (A010785). - Bernard Schott, May 09 2022

Extensions

Definition clarified by N. J. A. Sloane, Aug 19 2008
Name edited by M. F. Hasler, Nov 09 2019
Terms a(0) = a(1) = ... = a(9) = 0 prepended by Max Alekseyev, Jul 26 2024

A055017 Difference between sums of alternate digits of n starting with the last, i.e., (sum of ultimate digit of n, antepenultimate digit of n, ...) - (sum of penultimate digit of n, preantepenultimate digit 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
Offset: 0

Views

Author

Henry Bottomley, May 31 2000

Keywords

Comments

a(n) is a multiple of 11 iff n is divisible by 11.
Digital sum with alternating signs starting with a positive sign for the rightmost digit. - Hieronymus Fischer, Jun 18 2007
For n < 100, a(n) = (n mod 10 - floor(n/10)) = -A076313(n). - Hieronymus Fischer, Jun 18 2007

Examples

			a(123) = 3-2+1 = 2, a(9875) = 5-7+8-9 = -3.
		

Crossrefs

Cf. A225693 (alternating sum of digits).
Unsigned version differs from A040114 and A040115 when n=100 and from A040997 when n=101.
Cf. A004086.
Cf. analogous sequences for bases 2-9: A065359, A065368, A346688, A346689, A346690, A346691, A346731, A346732 and also A373605 (for primorial base).

Programs

  • Maple
    sumodigs := proc(n) local dg; dg := convert(n,base,10) ; add(op(1+2*i,dg), i=0..floor(nops(dg)-1)/2) ; end proc:
    sumedigs := proc(n) local dg; dg := convert(n,base,10) ; add(op(2+2*i,dg), i=0..floor(nops(dg)-2)/2) ; end proc:
    A055017 := proc(n) sumodigs(n)-sumedigs(n) ; end proc: # R. J. Mathar, Aug 26 2011
  • Python
    def A055017(n): return sum((-1 if i % 2 else 1)*int(j) for i, j in enumerate(str(n)[::-1])) # Chai Wah Wu, May 11 2022
  • Smalltalk
    "Recursive version for general bases"
    "Set base = 10 for this sequence"
    altDigitalSumRight: base
    | s |
    base = 1 ifTrue: [^self \\ 2].
    (s := self // base) > 0
      ifTrue: [^(self - (s * base) - (s altDigitalSumRight: base))]
      ifFalse: [^self]
    [by Hieronymus Fischer, Mar 23 2014]
    

Formula

From Hieronymus Fischer, Jun 18 2007, Jun 25 2007, Mar 23 2014: (Start)
a(n) = n + 11*Sum_{k>=1} (-1)^k*floor(n/10^k).
a(10n+k) = k - a(n), 0 <= k < 10.
G.f.: Sum_{k>=1} (x^k-x^(k+10^k)+(-1)^k*11*x^(10^k))/((1-x^(10^k))*(1-x)).
a(n) = n + 11*Sum_{k=10..n} Sum_{j|k,j>=10} (-1)^floor(log_10(j))*(floor(log_10(j)) - floor(log_10(j-1))).
G.f. expressed in terms of Lambert series: g(x) = (x/(1-x)+11*L[b(k)](x))/(1-x) where L[b(k)](x) = Sum_{k>=0} b(k)*x^k/(1-x^k) is a Lambert series with b(k) = (-1)^floor(log_10(k)) if k>1 is a power of 10, otherwise b(k)=0.
G.f.: (1/(1-x)) * Sum_{k>=1} (1+11*c(k))*x^k, where c(k) = Sum_{j>=2,j|k} (-1)^floor(log_10(j))*(floor(log_10(j))-floor(log_10(j-1))).
Formulas for general bases b > 1 (b = 10 for this sequence).
a(n) = Sum_{k>=0} (-1)^k*(floor(n/b^k) mod b).
a(n) = n + (b+1)*Sum_{k>=1} (-1)^k*floor(n/b^k). Both sums are finite with floor(log_b(n)) as the highest index.
a(n) = a(n mod b^k) + (-1)^k*a(floor(n/b^k)), for all k >= 0.
a(n) = a(n mod b) - a(floor(n/b)).
a(n) = a(n mod b^2) + a(floor(n/b^2)).
a(n) = (-1)^m*A225693(n), where m = floor(log_b(n)).
a(n) = (-1)^k*A225693(A004086(n)), where k = is the number of trailing 0's of n, formally, k = max(j | n == 0 (mod 10^j)).
a(A004086(A004086(n))) = (-1)^k*a(n), where k = is the number of trailing 0's in the decimal representation of n. (End)

A040997 Absolute value of first digit of n minus sum of other digits of n.

Original entry on oeis.org

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, 1, 0, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Offset: 1

Views

Author

Keywords

Comments

This is different from |A055017(n)| = |(x1 + x3 + ...) - (x2 + x4 + ...)|, where x1,...,xk are the digits of n. - M. F. Hasler, Nov 09 2019

Examples

			a(371) = |3-7-1| = 5.
		

Crossrefs

Programs

  • Haskell
    a040997 n = abs $ a000030 n - a007953 (a217657 n) -- Reinhard Zumkeller, Oct 10 2012
    
  • PARI
    apply( A040997(n)={abs(vecsum(n=digits(n))-n[1]*2)}, [1..199]) \\ M. F. Hasler, Nov 09 2019

Formula

If decimal expansion of n is x1 x2 ... xk then a(n) = |x1-x2-x3- ... -xk|.
a(n) = abs(A000030(n) - A007953(A217657(n))). - Reinhard Zumkeller, Oct 10 2012

Extensions

Name edited and incorrect formula deleted by M. F. Hasler, Nov 09 2019

A040163 a(n) is the absolute value of (the first digit of n minus the last digit of n).

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 0, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 5
Offset: 1

Views

Author

Keywords

Examples

			a(371) = abs(3 - 1) = 2.
a(567) = abs(5 - 7) = 2.
		

Crossrefs

Cf. A000030 (first digit of n), A010879 (last digit of n).

Programs

  • Mathematica
    Array[Abs[First@ # - Last@ #] &@ IntegerDigits@ # &, 106] (* Michael De Vlieger, Oct 15 2018 *)
  • PARI
    a(n) = my(digs = digits(n)); abs(digs[1] - digs[#digs]); \\ Michel Marcus, Sep 27 2013
    
  • PARI
    apply( {A040163(n)=abs(n\10^logint(n+!n,10)-n%10)}, [0..111]) \\ M. F. Hasler, Apr 22 2024
    
  • Python
    for n in range(1,51): print(abs(int(str(n)[0])-int(str(n)[-1]))) # David F. Marrs, Oct 14 2018

Formula

a(n) = abs(floor(n / 10 ^ floor(log_10(n))) - (n - floor(n / 10) * 10)) - David F. Marrs, Oct 14 2018

A365257 The five digits of a(n) and their four successive absolute first differences are all distinct.

Original entry on oeis.org

14928, 15829, 17958, 18259, 18694, 18695, 19372, 19375, 19627, 25917, 27391, 27398, 28149, 28749, 28947, 34928, 35917, 37289, 37916, 38926, 39157, 39578, 43829, 45829, 47289, 47916, 49318, 49681, 49687, 51869, 53719, 57391, 57398, 58926, 59318, 59681, 59687, 61973, 61974, 62983, 62985, 67958, 68149, 68749, 68947, 69157, 69578, 71952, 71953, 72691, 72698, 74619, 74982, 74986, 75193, 75196, 76859, 78259, 78694, 78695, 81394, 81395, 81539, 82941, 82943, 85179, 85629, 85971, 85976, 86749, 87269, 87593, 87596, 89372, 89375, 89627, 91647, 91735, 92658, 92834, 92851, 92854, 93518, 94182, 94186, 94768, 94782, 94786, 95281, 95287, 95867, 96278, 96815, 97158, 98273, 98274
Offset: 1

Views

Author

Keywords

Comments

The digit 0 is never present in a(n) and never appears as a first difference (as this would duplicate in both cases one of the 8 remaining digits involved).
The sequence ends with a(96) = 98274.
The only prime numbers with this property are 39157, 49681, 51869, 53719, 62983, 68749, 68947, 75193, 78259, 89627 and 95287.

Examples

			The five digits of a(1) = 14928 produce the four successive absolute first differences 3 (= 1 - 4), 5 (= 4 - 9), 7 (= 9 - 2) and 6 (= 2 - 8), resulting in nine distinct digits.
.1.4.9.2.8.
..3.5.7.6..
		

Crossrefs

Programs

  • Mathematica
    Select[Range[10000,99999],Sort@Join[IntegerDigits@#, Abs@Differences@IntegerDigits@#]==Range@9&]

A365258 The four digits of a(n), their three successive absolute first differences and their two successive absolute second differences are all distinct.

Original entry on oeis.org

2983, 3892, 4197, 4917, 5298, 5928, 7194, 7398, 7914, 7938, 8139, 8295, 8329, 8397, 8925, 8937, 9238, 9318
Offset: 1

Views

Author

Keywords

Comments

The digit 0 is never present in a(n) and never appears as a first or a second difference (as this would duplicate in both cases one of the 8 remaining digits involved).
The sequence ends with a(18) = 9318.

Examples

			2983 is a term since its three successive absolute first differences 7 (= 2 - 9), 1 (= 9 - 8), 5 (= 8 - 3) and the successive absolute second differences 6 (= 7 - 1) and 4 (= 1 - 5), are nine distinct digits.
  2 9 8 3
   7 1 5
    6 4
		

Crossrefs

Programs

  • Mathematica
    Select[Range[1000,9999],Sort@Join[IntegerDigits@#, s=Abs@Differences@IntegerDigits@#, Abs@Differences@s]==Range@9&]
Showing 1-6 of 6 results.