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

A056964 a(n) = n + reversal of digits of n.

Original entry on oeis.org

0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 66, 77, 88, 99, 110
Offset: 0

Views

Author

Henry Bottomley, Jul 18 2000

Keywords

Comments

If n has an even number of digits then a(n) is a multiple of 11.
Also called the Reverse and Add!, or RADD operation. Iteration of this function leads to the definition of Lychrel and related numbers, cf. A023108, A063048, A088753, A006960, and many others. - M. F. Hasler, Apr 13 2019

Examples

			a(17) = 17 + 71 = 88.
		

Crossrefs

Differs from A052008 when n=101 and a(101)=202 while A052008(101)=121
Cf. A036839.

Programs

Formula

a(n) = n + A004086(n) = 2*n - A056965(n).
n < a(n) < 11n for n > 0. - Charles R Greathouse IV, Nov 17 2022

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

A072140 The period length of the 'Reverse and Subtract' trajectory of n is greater than 1.

Original entry on oeis.org

1012, 1023, 1034, 1045, 1067, 1078, 1089, 1100, 1122, 1133, 1144, 1155, 1177, 1188, 1199, 1210, 1232, 1243, 1254, 1265, 1287, 1298, 1320, 1342, 1353, 1364, 1375, 1397, 1408, 1430, 1452, 1463, 1474, 1485, 1507, 1518, 1540, 1562, 1573, 1584, 1595, 1606
Offset: 1

Views

Author

Klaus Brockhaus, Jun 24 2002

Keywords

Comments

'Reverse and Subtract' (cf. A072137) is defined by x -> |x - reverse(x)|. There is no number k > 0 such that |k - reverse(k)| = k, so 0 is the only period with length 1. Consequently this sequence consists of the numbers n such that repeated application of 'Reverse and Subtract' does not lead to a palindrome. It is an analog of A023108, which uses 'Reverse and Add'. - A072141, A072142, A072143 give the numbers which generate periods of length 2, 14, 22 respectively.

Examples

			1012 -> |1012 - 2101| = 1089 -> |1089 - 9801| = 8712 -> |8712 - 2178| = 6534 -> |6534 - 4356| = 2178 -> |2178 - 8712| = 6534; the period of the trajectory is 6534, 2178 and a palindrome is never reached.
		

Crossrefs

Programs

  • Haskell
    import Data.List (find, findIndices, inits)
    import Data.Maybe (fromJust)
    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
    a072140_list = findIndices (> 1) $
                   map (length . snd . spanCycle (abs . a056965)) [0..]
    -- eop.
    -- Reinhard Zumkeller, Oct 24 2010

A068396 n-th prime minus its reversal.

Original entry on oeis.org

0, 0, 0, 0, 0, -18, -54, -72, -9, -63, 18, -36, 27, 9, -27, 18, -36, 45, -9, 54, 36, -18, 45, -9, 18, 0, -198, -594, -792, -198, -594, 0, -594, -792, -792, 0, -594, -198, -594, -198, -792, 0, 0, -198, -594, -792, 99, -99, -495
Offset: 1

Views

Author

Reinhard Zumkeller, Mar 08 2002

Keywords

Comments

a(n) = 0 for n in A075807. - Michel Marcus, Sep 27 2017
All terms are divisible by 9. - Zak Seidov, Jun 05 2021

Examples

			a(10) = 29 - 92 = -63;
a(20) = 71 - 17 = 54.
		

Crossrefs

Programs

  • Haskell
    a068396 n = p - a004086 p  where p = a000040 n
    -- Reinhard Zumkeller, Feb 04 2014
    
  • Mathematica
    #-IntegerReverse[#]& /@ Prime[Range[50]] (* Harvey P. Dale, Dec 20 2012 *)
  • PARI
    a(n) = prime(n) - fromdigits(Vecrev(digits(prime(n)))); \\ Michel Marcus, Sep 27 2017
    
  • Python
    from sympy import prime
    def a(n): pn = prime(n); return pn - int(str(pn)[::-1])
    print([a(n) for n in range(1, 50)]) # Michael S. Branicky, Jun 05 2021

Formula

a(n) = A000040(n) - A004087(n).
a(n) = A056965(A000040(n)). - Michel Marcus, Sep 27 2017

A070837 Smallest number k such that abs(k - R(k)) = 9n, where R(k) is digit reversal of k (A004086); or 0 if no such k exists.

Original entry on oeis.org

10, 13, 14, 15, 16, 17, 18, 19, 90, 1011, 100, 0, 0, 0, 0, 0, 0, 0, 0, 1021, 1090, 103, 0, 0, 0, 0, 0, 0, 0, 1031, 1080, 0, 104, 0, 0, 0, 0, 0, 0, 1041, 1070, 0, 0, 105, 0, 0, 0, 0, 0, 1051, 1060, 0, 0, 0, 106, 0, 0, 0, 0, 1061, 1050, 0, 0, 0, 0, 107, 0, 0, 0, 1071, 1040, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Amarnath Murthy, May 12 2002

Keywords

Comments

If 9n < 1000, k has at most 5 digits, and abs(k - R(k)) = 9n, then 10 must divide n. - Sascha Kurz, Jan 02 2003

Crossrefs

Programs

  • Mathematica
    a = Table[0, {50}]; Do[d = Abs[n - FromDigits[ Reverse[ IntegerDigits[n]]]] / 9; If[d < 51 && a[[d]] == 0, a[[d]] = n], {n, 1, 10^7}]; a
  • Python
    def back_difference(n):
        r = int(str(n)[::-1])
        return abs(r-n)
    def a070837(n):
        i = 0
        while True:
            if back_difference(i)==9*n:
                return i
            i+=1
    # Christian Perfect, Jul 23 2015

Extensions

More terms from Sascha Kurz, Jan 02 2003
a(21) corrected by Christian Perfect, Jul 23 2015

A256756 a(n) = bitwise XOR of n and the reverse of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 25, 18, 39, 60, 45, 86, 67, 72, 22, 25, 0, 55, 50, 45, 36, 83, 78, 65, 29, 18, 55, 0, 9, 22, 27, 108, 117, 122, 44, 39, 50, 9, 0, 27, 110, 101, 100, 111, 55, 60, 45, 22, 27, 0, 121, 114, 111, 100, 58, 45, 36, 27, 110, 121
Offset: 0

Views

Author

Alois P. Heinz, Apr 09 2015

Keywords

Crossrefs

Programs

  • Maple
    a:= n-> Bits[Xor](n, (s-> parse(cat(s[-i]$i=1..length(s))))(""||n)):
    seq(a(n), n=0..80);
  • Mathematica
    Table[BitXor[n,FromDigits[Reverse[IntegerDigits[n]]]],{n,0,65}] (* Ivan N. Ianakiev, Apr 10 2015 *)
  • PARI
    a(n) = bitxor(n, subst(Polrev(digits(n)), x, 10)); \\ Michel Marcus, Apr 10 2015

Formula

a(n) = A003987(n, A004086(n)).

A256754 a(n) = bitwise AND of n and the reverse of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 4, 13, 8, 3, 16, 1, 16, 19, 0, 4, 22, 0, 8, 16, 26, 8, 16, 28, 2, 13, 0, 33, 34, 33, 36, 1, 2, 5, 0, 8, 8, 34, 44, 36, 0, 10, 16, 16, 0, 3, 16, 33, 36, 55, 0, 9, 16, 27, 4, 16, 26, 36, 0, 0, 66, 64, 68, 64, 6, 1, 8, 1, 10
Offset: 0

Views

Author

Alois P. Heinz, Apr 09 2015

Keywords

Crossrefs

Programs

  • Maple
    a:= n-> Bits[And](n, (s-> parse(cat(s[-i]$i=1..length(s))))(""||n)):
    seq(a(n), n=0..80);
  • Mathematica
    Table[BitAnd[n,FromDigits[Reverse[IntegerDigits[n]]]],{n,0,74}] (* Ivan N. Ianakiev, Apr 10 2015 *)
  • PARI
    a(n) = bitand(n, subst(Polrev(digits(n)), x, 10)); \\ Michel Marcus, Apr 10 2015

Formula

a(n) = A004198(n,A004086(n)).

A256755 a(n) = bitwise OR of n and the reverse of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 29, 31, 47, 63, 61, 87, 83, 91, 22, 29, 22, 55, 58, 61, 62, 91, 94, 93, 31, 31, 55, 33, 43, 55, 63, 109, 119, 127, 44, 47, 58, 43, 44, 63, 110, 111, 116, 127, 55, 63, 61, 55, 63, 55, 121, 123, 127, 127, 62, 61, 62, 63, 110
Offset: 0

Views

Author

Alois P. Heinz, Apr 09 2015

Keywords

Crossrefs

Programs

  • Maple
    a:= n-> Bits[Or](n, (s-> parse(cat(s[-i]$i=1..length(s))))(""||n)):
    seq(a(n), n=0..80);
  • Mathematica
    Table[BitOr[n,FromDigits[Reverse[IntegerDigits[n]]]],{n,0,64}] (* Ivan N. Ianakiev, Apr 10 2015 *)
  • PARI
    a(n) = bitor(n, subst(Polrev(digits(n)), x, 10)); \\ Michel Marcus, Apr 10 2015

Formula

a(n) = A003986(n,A004086(n)).

A347688 Let c (resp. C) be the smallest (resp. largest) number that can be obtained by cyclically permuting the digits of n; a(n) = C - c.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 9, 18, 27, 36, 45, 54, 63, 72, 18, 9, 0, 9, 18, 27, 36, 45, 54, 63, 27, 18, 9, 0, 9, 18, 27, 36, 45, 54, 36, 27, 18, 9, 0, 9, 18, 27, 36, 45, 45, 36, 27, 18, 9, 0, 9, 18, 27, 36, 54, 45, 36, 27, 18, 9, 0, 9, 18, 27, 63, 54, 45, 36, 27, 18, 9, 0, 9, 18, 72, 63, 54, 45, 36, 27, 18, 9, 0, 9, 81, 72, 63, 54, 45, 36, 27, 18, 9, 0, 99, 99, 189, 279, 369, 459, 549, 639, 729, 819, 99, 0, 99
Offset: 0

Views

Author

N. J. A. Sloane, Sep 22 2021, following a suggestion from Joseph Rozhenko

Keywords

Comments

Agrees with A151949 for n <= 101.
All terms are multiples of 9 (cf. A347689).
Repeatedly applying the operation of subtracting the smallest cyclic permutation from the largest produces interesting sequences. It appears that n-digit numbers converge to a small number m << n of loops. Any 3-digit number converges to one of two loops of length 3: (189, 729, 675) and (378, 459, 486); any 4-digit number to either of (189, 729, 675) or a loop of length 25; any 5-digit number to one of three loops of length 3: (38007, 79335, 59778), (48780, 82926, 65853), or (29889, 69003, 89667), and so on. For 6-digit numbers there are 10 loops (of lengths 1, 2, 3, 10, 12 or 60). - Joseph Rozhenko, Oct 05 2021
For any cyclic number N, there must exist a cyclic permutation P of N for which a(P) = P. - Joseph Rozhenko, Oct 07 2021
An interesting plot of this sequence comes up when the axes are not n vs. a(n), but rather C vs. c. In other words, each number a(n) is represented on the X axis by C (largest number that can be obtained by cyclically permuting the digits of n) and on the Y axis as c (smallest number that can be obtained by cyclically permuting the digits of n). - Joseph Rozhenko, Jan 26 2022

Examples

			If n = 102, c = 21, C = 210, a(102) = 210 - 21 = 189.
		

Crossrefs

Programs

  • Maple
    A347688 := proc(n)
            local dgs,C,c,ndgs,r ;
            dgs := convert(n,base,10) ;
            ndgs := nops(dgs) ;
            C := digcatL(dgs) ;
            c := C ;
            for r from 0 to ndgs-1 do
                    C := max(C,digcatL(dgs)) ;
                    c := min(c,digcatL(dgs)) ;
                    dgs := ListTools[Rotate](dgs,1) ;
            end do:
            C-c ;
    end proc: # R. J. Mathar, Sep 27 2021
  • Mathematica
    {0}~Join~Table[First@Differences@MinMax[FromDigits/@(RotateLeft[IntegerDigits@n,#]&/@Range@IntegerLength@n)],{n,112}] (* Giorgos Kalogeropoulos, Sep 22 2021 *)
  • PARI
    a(n, base=10) = { my (c=n, C=n, d=digits(n, base)); for (k=1, #d, my (r=fromdigits(concat(d[k+1..#d], d[1..k]), base)); c=min(c, r); C=max(C, r)); C-c } \\ Rémy Sigrist, Sep 22 2021
    
  • Python
    def a(n):
        s = str(n)
        cyclic_perms = [int("".join(s[i:] + s[:i])) for i in range(len(s))]
        c, C = min(cyclic_perms), max(cyclic_perms)
        return C - c
    print([a(n) for n in range(113)]) # Michael S. Branicky, Sep 26 2021

Formula

a(n) = 0 iff n belongs to A010785. - Rémy Sigrist, Sep 22 2021

Extensions

More than the usual number of terms are shown in order to distinguish this from similar sequences.

A055947 n - reversal of base 3 digits of n (written in base 10).

Original entry on oeis.org

0, 0, 0, 2, 0, -2, 4, 2, 0, 8, 0, -8, 8, 0, -8, 8, 0, -8, 16, 8, 0, 16, 8, 0, 16, 8, 0, 26, 0, -26, 20, -6, -32, 14, -12, -38, 32, 6, -20, 26, 0, -26, 20, -6, -32, 38, 12, -14, 32, 6, -20, 26, 0, -26, 52, 26, 0, 46, 20, -6, 40, 14, -12, 58, 32, 6, 52, 26, 0, 46, 20, -6, 64, 38, 12, 58, 32, 6, 52, 26, 0, 80, 0, -80, 56, -24, -104, 32, -48
Offset: 0

Views

Author

Henry Bottomley, Jul 18 2000

Keywords

Comments

a(n) is even.

Examples

			For n = 5, the reversal of base 3 digits of n (written in base 10) is 7. So, a(5) = 5 - 7 = -2. - _Indranil Ghosh_, Feb 01 2017
		

Crossrefs

Programs

  • Mathematica
    Table[n-FromDigits[Reverse[IntegerDigits[n,3]],3],{n,0,90}] (* Harvey P. Dale, May 14 2022 *)
  • PARI
    a(n) = n - fromdigits(Vecrev(digits(n, 3)), 3); \\ Michel Marcus, Aug 09 2019

Formula

a(n) = n - A030102(n).
Showing 1-10 of 26 results. Next