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.

A072137 Length of the preperiodic part of the 'Reverse and Subtract' trajectory of n.

Original entry on oeis.org

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

Views

Author

Klaus Brockhaus, Jun 24 2002

Keywords

Comments

'Reverse and Subtract' (cf. A070837, A070838) is defined by x -> |x - reverse(x)|, where reverse(x) is the digit reversal of x.
For every n the trajectory eventually becomes periodic, since 'Reverse and Subtract' does not increase the number of digits and so the set of available terms is finite. For small n the period length is 1, the periodic part consists of 0's, the last term of the preperiodic part is a palindrome.
The first n with period length 2 and a nontrivial periodic part is 1012 (cf. A072140).
This sequence is a weak analog of A033665, which uses 'Reverse and Add'.

Examples

			a(15) = 4 since 15 -> |15- 51| = 36 -> |36 - 63| = 27 -> |27 - 72| = 45 -> |45 - 54| = 9.
		

Crossrefs

Programs

  • Haskell
    import Data.List(inits, find); import Data.Maybe(fromJust)
    a072137 :: Int -> Int
    a072137 = length . fst . spanCycle (abs . a056965) where
       spanCycle :: Eq a => (a -> a) -> a -> ([a],[a])
       spanCycle f x = fromJust $ find (not . null . snd) $
                                  zipWith (span . (/=)) xs $ inits xs
                       where xs = iterate f x
    -- Reinhard Zumkeller, Oct 24 2010
  • Mathematica
    a[n_] := (k = 0; FixedPoint[ (k++; Abs[# - FromDigits[ Reverse[ IntegerDigits[#] ] ] ]) &, n]; k - 1); Table[ a[n], {n, 0, 104}] (* Jean-François Alcover, Dec 01 2011 *)

A072138 Smallest k whose 'Reverse and Subtract' trajectory has a preperiodic part of length n.

Original entry on oeis.org

0, 1, 10, 16, 14, 15, 13, 1011, 1017, 1037, 1027, 1014, 1013, 1028, 100113, 100104, 100145, 100134, 100103, 100112, 100133, 100187, 100114, 100128, 100194, 100107, 100307, 100277, 100413, 100345, 100429, 100215, 100427, 100214, 100433, 100335
Offset: 0

Views

Author

Klaus Brockhaus, Jun 24 2002

Keywords

Comments

'Reverse and Subtract' (cf. A072137) is defined by x -> |x - reverse(x)|. For small n the last term of the preperiodic part of the trajectory (cf. A072139) is a palindrome, so this sequence is a weak analog of A033665, which uses 'Reverse and Add'. - 1012 is the first n such that last term of the preperiodic part is not palindromic (cf. A072140).

Examples

			a(8) = 1017, since 1017 is the smallest number whose 'Reverse and Subtract' trajectory has eight preperiodic terms: 1017 -> 6084 -> 1278 -> 7443 -> 3996 -> 2997 -> 4995 -> 999.
		

Crossrefs

A072147 Records for the length of the preperiodic part of the 'Reverse and Subtract' trajectories.

Original entry on oeis.org

0, 1, 2, 6, 7, 12, 13, 18, 25, 40, 45, 47, 48, 49, 55, 56, 60, 62, 63, 64, 66, 71, 72, 75, 78, 81, 106, 108, 111, 112, 114, 115, 119, 121, 122, 130, 132, 133, 135, 147, 148, 149, 151, 156
Offset: 1

Views

Author

Klaus Brockhaus, Jun 24 2002

Keywords

Comments

Successive maxima in sequence A072137. A072146 gives the corresponding starting points. - This sequence is a weak analog of A065199, which uses 'Reverse and Add'.

Examples

			6 is a record, since the preperiodic part of the trajectory of 13 has length 6 and for k < 13 the preperiodic part has a smaller length (at most 2).
		

Crossrefs

Extensions

a(18) inserted, a(25) corrected, a(29) through a(44) added by Alexander Pesch (alex-physics(AT)gmx.net), May 29 2007
Edited by N. J. A. Sloane, Dec 01 2007
Showing 1-3 of 3 results.