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 *)

A070838 Smallest prime p such that |p - R(p)| = 9n, where R(n) is digit reversal of n, A004086; or 0 if no such prime exists.

Original entry on oeis.org

23, 13, 41, 37, 61, 17, 29, 19, 0, 1231, 211, 0, 0, 0, 0, 0, 0, 0, 0, 1021, 2903, 103, 0, 0, 0, 0, 0, 0, 0, 1031, 2081, 0, 401, 0, 0, 0, 0, 0, 0, 1151, 4073, 0, 0, 307, 0, 0, 0, 0, 0, 1051, 2281, 0, 0, 0, 227, 0, 0, 0, 0, 1061, 2161, 0, 0, 0, 0, 107, 0, 0, 0, 1181, 2371, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Amarnath Murthy, May 12 2002

Keywords

Crossrefs

Cf. A070837.

Extensions

Corrected and extended by Sascha Kurz, Jan 02 2003

A383887 Smallest non-palindromic number that is congruent to its reverse mod n.

Original entry on oeis.org

10, 13, 10, 15, 16, 13, 18, 19, 10, 1011, 100, 15, 1017, 1027, 16, 1025, 1039, 13, 1048, 1021, 18, 103, 1026, 19, 1026, 1017, 14, 1033, 1013, 1011, 1068, 1049, 100, 1039, 1046, 15, 1000, 1055, 1017, 1041, 1066, 1027, 1048, 105, 16, 1077, 1032, 1025, 1014, 1051, 1039, 1017, 1103, 17, 106, 1065
Offset: 1

Views

Author

Erick B. Wong, May 29 2025, at the suggestion of Lanny Wong

Keywords

Comments

Comparable to A070837, but such a number provably exists: if n is coprime to 10 then take 10^k where k is the order of 10 mod n; else take a>b>0 such that n divides 10^a - 10^b, then the number 10^(a+b) + 10^b + 1 works.
The n-th term in this sequence is equal to the first nonzero term of A070837 that occurs at an index divisible by n/gcd(n,9).

Examples

			For n=6, a(6)=13 is congruent to 31 mod 6.
For n=10, note that any number of 3 or fewer digits is necessarily a palindrome if the first digit equals the last, and 1011 is the first 4-digit non-palindrome.
		

Crossrefs

Programs

  • Mathematica
    seq[len_] := Module[{s = Table[0, {len}], c = 0, k = 9, d}, While[c < len, k++; krev = IntegerReverse[k]; If[k != krev, d = Select[Divisors[Abs[k - krev]], # <= len &]; Do[If[s[[d[[i]]]] == 0, s[[d[[i]]]] = k; c++], {i, 1, Length[d]}]]]; s]; seq[60] (* Amiram Eldar, May 31 2025 *)
  • PARI
    a(n) = my(k=1, d=digits(k), rd=Vecrev(d)); while(!((d != rd) && Mod(fromdigits(rd), n) == k), k++; d=digits(k); rd=Vecrev(d)); k; \\ Michel Marcus, May 30 2025
  • Python
    from functools import partial
    from itertools import count
    def accept(mod, k):
        r = int(str(k)[::-1])
        return r != k and (r-k) % mod == 0
    def a(n):
        return next(filter(partial(accept, n), count(10)))
    print([a(n) for n in range(1,57)])
    
Showing 1-3 of 3 results.