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 31 results. Next

A329200 The ghost iteration (A): add or subtract the number formed by absolute differences of digits (A040115), according to parity (even or odd).

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 15, 11, 19, 11, 23, 11, 27, 22, 20, 22, 22, 26, 22, 30, 22, 34, 22, 27, 33, 31, 33, 33, 37, 33, 41, 33, 45, 44, 38, 44, 42, 44, 44, 48, 44, 52, 44, 45, 55, 49, 55, 53, 55, 55, 59, 55, 63, 66, 56, 66, 60, 66, 64, 66, 66, 70, 66, 63, 77, 67, 77, 71, 77
Offset: 0

Views

Author

Eric Angelini and M. F. Hasler, Nov 09 2019

Keywords

Comments

Sequence A040115 is most naturally extended to 0 (empty sum) for single-digit arguments; that's what we use here. This value is added to n if even, subtracted if odd.
Repdigit numbers are the fixed points. Other starting values end in nontrivial loops under iterations of this map, like 11090 -> 10891 -> 12709 -> 11130 -> 11107 -> 11090 etc. Table A329196 lists these cycles, A329197 their lengths.
A329198 gives the size of n's orbit, i.e., the length of the trajectory until the terminating cycle is covered.

Examples

			For n = 101, the number formed by the absolute differences of digits is 11, since this is odd it is subtracted from n, so a(101) = 101-11 = 90.
		

Crossrefs

Cf. A040115, A329201 (variant B: add/subtract if odd/even).
Cf. A329196 (cycles), A329197 (lengths), A329198 (size of orbit of n).

Programs

  • PARI
    apply( A329200(n)={n+(-1)^(n=fromdigits(abs((n=digits(n+!n))[^-1]-n[^1])))*n}, [1..199])

Formula

a(n) = n + (-1)^d*d where d = A040115(n), 0 for n < 10.

A329201 The ghost iteration (B): add or subtract the number formed by absolute differences of digits (A040115), according to parity (odd or even).

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 13, 11, 17, 11, 21, 11, 25, 11, 18, 22, 22, 24, 22, 28, 22, 32, 22, 36, 33, 29, 33, 33, 35, 33, 39, 33, 43, 33, 36, 44, 40, 44, 44, 46, 44, 50, 44, 54, 55, 47, 55, 51, 55, 55, 57, 55, 61, 55, 54, 66, 58, 66, 62, 66, 66, 68, 66, 72, 77, 65, 77, 69, 77, 73, 77
Offset: 0

Views

Author

Eric Angelini and M. F. Hasler, Nov 09 2019

Keywords

Comments

Sequence A040115 is most naturally extended to 0 (empty sum) for single-digit arguments; that's what we use for n < 10 here. This value is subtracted from n if even, added if odd.
A040115 is zero iff the argument is a repdigit (A010785), which therefore are the fixed points of this map A329201. All small starting values reach a fixed point, but larger values may enter a nontrivial cycle (or "loop").
See the table A329342 for the list of these cycles.

Examples

			For n = 101, the number formed by the absolute differences of digits is 11. Since this is odd it is added to n, so a(101) = 101 + 11 = 112.
		

Crossrefs

Cf. A040115, A329200 (variant A: add/subtract if even/odd), A010785 (fixed points).
Cf. A329342 (list of cycles).

Programs

  • PARI
    apply( A329201(n)={n-(-1)^(n=fromdigits(abs((n=digits(n+!n))[^-1]-n[^1])))*n}, [1..199])

Formula

a(n) = n - (-1)^d*d where d = A040115(n), 0 for n < 10.

A087597 Triangular numbers m such that A040115(m) is also triangular.

Original entry on oeis.org

0, 1, 3, 6, 10, 21, 28, 36, 45, 55, 66, 78, 105, 171, 465, 528, 561, 666, 2211, 4465, 7503, 16836, 18336, 22791, 44850, 53628, 55278, 82621, 105111, 114003, 333336, 427350, 828828, 2220778, 2256750, 3136260, 3373503, 3454506, 3927003, 5443350, 6175855, 7552441
Offset: 1

Views

Author

Amarnath Murthy, Sep 18 2003

Keywords

Comments

Conjecture: Sequence is infinite.

Examples

			171 is a member as A040115(171) = 66 is also a triangular number.
		

Crossrefs

Programs

  • Maple
    q:= n-> issqr(1+8*(l-> parse(cat(0,seq(abs(l[-i]-l[1-i])
             , i=2..nops(l)))))(convert(n, base, 10))):
    select(q, [i*(i+1)/2$i=0..10000])[];  # Alois P. Heinz, Jul 27 2024
  • PARI
    dd(k)={ local(kshf,res,dig,odig,p) ; kshf=k ; res=0 ; odig=kshf % 10 ; p=0 ; while(kshf>9, kshf=floor(kshf/10) ; dig=kshf % 10 ; res += 10^p*abs(dig-odig) ; odig=dig ; p++ ; ) ; return(res) ; } isA000217(n)={ if( issquare(1+8*n), return(1), return(0) ) ; } isA087597(n)={ if( isA000217(n) && isA000217(dd(n)), return(1), return(0) ) ; } { for(k=10,10000000, if(isA087597(k), print1(k,",") ; ) ; ) ; } \\ R. J. Mathar, Nov 19 2006

Extensions

Corrected and extended by R. J. Mathar, Nov 19 2006
Definition clarified, offset corrected, and terms 0,1,3,6 prepended by Max Alekseyev, Jul 27 2024

A087598 Numbers m such that all terms in the sequence m, A040115(m), A040115(A040115(m)), ..., 0 are triangular numbers (A000217).

Original entry on oeis.org

0, 1, 3, 6, 10, 21, 28, 36, 45, 55, 66, 78, 171, 465, 528, 666, 2211, 4465, 22791, 333336
Offset: 1

Views

Author

Amarnath Murthy, Sep 18 2003

Keywords

Comments

a(21) would need to have A040115(a(21)) among the listed terms. Equation A040115(x) = t for any term t reduces to computing integral points on a finite number of elliptic curve. Computation shows that no any new number can be obtained this way. Hence the sequence is finite and complete. - Max Alekseyev, Aug 02 2024

Examples

			528 is a term since A040115(528) = 36, A040115(36) = 3, A040115(3) = 0, where 528, 36, 3, and 0 are triangular numbers.
		

Crossrefs

Programs

  • Mathematica
    trnoQ[n_]:=IntegerQ[(Sqrt[8n+1]-1)/2]; oknQ[n_]:=Module[{ll= NestWhileList[FromDigits[Abs[Differences[IntegerDigits[#]]]]&, n, #>9&]}, Length[ll]>1&&And@@trnoQ/@ll]; Select[Accumulate[Range[ 2000000]],oknQ] (* Harvey P. Dale, May 15 2011 *)
  • PARI
    dd(k)={ local(kshf,res,dig,odig,p) ; kshf=k ; res=0 ; odig=kshf % 10 ; p=0 ; while(kshf>9, kshf=floor(kshf/10) ; dig=kshf % 10 ; res += 10^p*abs(dig-odig) ; odig=dig ; p++ ; ) ; return(res) ; } isA000217(n)={ if( issquare(1+8*n), return(1), return(0) ) ; } A000217(n)={ return(n*(n+1)/2) ; } isA087598(n)={ local(nredu) ; nredu=n ; while( nredu>10, if( isA000217(nredu), nredu=dd(nredu), return(0) ) ; ) ; if( isA000217(nredu), return(1), return(0) ) ; } { for(k=4,1000000, if(isA087598(A000217(k)), print1(A000217(k),",") ; ) ; ) ; } \\ R. J. Mathar, Nov 19 2006

Extensions

Corrected and extended by R. J. Mathar, Nov 19 2006
Name clarified and terms 0,1,3,6 prepended by Max Alekseyev, Jul 26 2024

A328680 The number of iterations before a repeated value appears when starting from n and performing the iterative cycle as described in the comments, which involves setting the next iterative number to either A053392 or A040115 depending on the current numbers' size relative to n.

Original entry on oeis.org

2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5
Offset: 1

Views

Author

Scott R. Shannon, Dec 03 2019

Keywords

Comments

This sequence is based on the following iterative cycle. Start with n, set m = A040115(n), the concatenation of the absolute values of differences between adjacent digits, and then repeat the following until the number m has been previously seen: if m is greater than n, let m = A040115(m), otherwise let m = A053392(m), the concatenation of the sums of pairs of adjacent digits.
For all starting values n the iteration eventually converges to 0 or else goes into a cycle of finite length. When the number m gets larger than the iteration's starting value n it will always have its magnitude decreased by the operation m = A040115(m), while m = A053392(m) can either increase or decrease its magnitude, depending on the digit values of m. This has the overall effect of never allowing the iterative values to increase without limit as is seen in the similar iterations A328975 and A329624.
All the values of A053393 are seen as repeating values in this sequence, although this sequence has significantly more; probably an infinite number, although this is unknown. The first nonzero repeating value is not seen until a(9090), which forms the two-member loop of 999 -> 1818 -> 999. The first starting value that leads to an m value greater than the initial starting value is a(10090), see examples below. A330159 lists the starting values which are also the first repeating value.
For the first 20 million terms the longest iterative sequence is seen for a(18505180) which takes 457 steps before reaching 0. See attached link. The longest found looping sequence is for a(14106482) which reaches 1040103 after 5 steps and then again after 116 steps, forming a loop of length 111. The largest number found which starts the repeating loop is for a(9265011) which reaches 1411131715 after 9 iterations and then again after 41 iterations.
From a(12) to a(99) the sequence repeats a pattern of ten 3's followed by a 2. After that, a(100) = 4 and the terms begin to show a slow average increase in value.

Examples

			a(10) = 3 as A040115(10) = 1, A053392(1) = 0, and A053392(0) = 0, taking three steps to repeat from 10.
a(1060) = 7 as A040115(1060) = 166, A053392(166) = 712, A053392(712) = 83, A053392(83) = 11, A053392(11) = 2, A053392(2) = 0, A053392(0) = 0, taking seven steps to repeat from 1060.
a(10090) = 11 as A040115(10090) = 1099, A053392(1099) = 1918, A053392(1918) = 10109, A040115(10109) = 1119, A053392(1119) = 2210, A053392(2210) = 431, A053392(431) = 74, A053392(74) = 11, A053392(11) = 2, A053392(2) = 0, A053392(0) = 0, taking eleven steps to repeat from 11090.
		

Crossrefs

A113608 Apply the map k -> A040115(k) repeatedly to n until a single digit is reached.

Original entry on oeis.org

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

Views

Author

Amarnath Murthy, Nov 09 2005

Keywords

Comments

Leading zeros at any intermediate result are discarded. The first terms, from n=10 to n=99, are identical to A040115. - R. J. Mathar, Aug 28 2007

Examples

			a(1396) = 1 because A040115(1396) = 263, A040115(263) = 43, A040115(43) = 1.
a(1237584965) = 1 from 6-fold application of A040115: 1237584965 -> 114234531 -> 3211122 -> 110010 -> 01011 = 1011 -> 110 -> 01 -> 1.
		

Crossrefs

Cf. A040115.

Programs

  • Maple
    A040115 := proc(n) local digs,digsdiff,i; digsdiff := [] ; digs := convert(n,base,10) ; for i from 2 to nops(digs) do digsdiff := [op(digsdiff),abs(op(i,digs)-op(i-1,digs))] ; od; add( op(i,digsdiff)*10^(i-1),i=1..nops(digsdiff)) ; end:
    A113608 := proc(n) local a; a := A040115(n) ; while a>9 do a := A040115(a) ; od; RETURN(a) ; end: seq(A113608(n),n=10..110) ; # R. J. Mathar, Aug 28 2007
  • Mathematica
    a[n_] := NestWhile[FromDigits[Abs[Differences[IntegerDigits[#]]]] &, n, # > 9 &]; Array[a, 120, 10] (* Amiram Eldar, Nov 12 2024 *)

Extensions

Edited and extended by R. J. Mathar, Aug 28 2007
Further edited by N. J. A. Sloane, Aug 19 2008

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

A329197 Length of the n-th nontrivial cycle of the "ghost iteration" A329200.

Original entry on oeis.org

5, 6, 3, 7, 5, 9, 6, 3, 3, 5, 3, 3, 6, 3, 3, 3, 5, 3, 3, 6, 3, 3, 3, 3, 5, 3, 3, 6, 3, 17, 3, 11, 3, 3, 3, 5, 3, 3, 6, 6, 3, 17, 3, 3, 3, 3, 5, 7, 6
Offset: 1

Views

Author

M. F. Hasler, Nov 10 2019

Keywords

Comments

A329200 consists in adding or subtracting the number A040115(n) whose digits are the differences of adjacent digits of n, depending on its parity.
Repdigits A010785 are fixed points of this map, but some numbers enter nontrivial cycles. This sequence gives the length of these cycles, ordered by their smallest member, as they are listed in the table A329196. See there for more information.

Examples

			The first cycle of A329200 is row 1 of A329196, (8290, 8969, 9102), of length 3 = a(1).
The second cycle of A329200 is row 2 of A329196, (17998, 24199, 21819, 20041, 22084, 21800, 20020), of length 7 = a(2).
		

Crossrefs

Cf. A329196, A329200, A329198, A329342 (variant using A329201).

Programs

  • PARI
    /* change T to #T in print statement of code for A329196 */

Extensions

a(9)-a(35) from Scott R. Shannon, Nov 12 2019
a(36)-a(49) from Lars Blomberg, Nov 15 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
Showing 1-10 of 31 results. Next