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

A099009 Fixed points of the Kaprekar mapping f(n) = n' - n'', where in n' the digits of n are arranged in descending, in n'' in ascending order.

Original entry on oeis.org

0, 495, 6174, 549945, 631764, 63317664, 97508421, 554999445, 864197532, 6333176664, 9753086421, 9975084201, 86431976532, 555499994445, 633331766664, 975330866421, 997530864201, 999750842001, 8643319766532, 63333317666664
Offset: 1

Views

Author

Klaus Brockhaus, Sep 22 2004

Keywords

Comments

There are no seven-digit fixed points.
Let d(n) denote n repetitions of the digit d. The sequence includes the following for all n>=0: 5(n)499(n)4(n)5, 63(n)176(n)4, 8643(n)1976(n)532. - Jens Kruse Andersen, Oct 04 2004
0's in n giving leading 0's in n'' is allowed.
For every natural number n let n' and n" be the numbers obtained by arranging the digits of n into decreasing and increasing order, and let f(n)=n'-n". It is known that the number 6174 is invariant under this transformation and that applying f a certain number of times to a number n with four digits the numbers 0, 495 or 6174 are always reached. - Vincenzo Librandi, Nov 17 2010
Each term of A055162(n) corresponds to A099009(n+1), with its digits being reordered in the ascending manner. - Alexander R. Povolotsky, Apr 27 2012
All terms of this sequence are divisible by nine, a(n)/9 = A132155(n). - Alexander R. Povolotsky, Apr 29 2012
A055160 differs from this sequence only at the positions of two terms in it: 554999445 and 555499994445. - Alexander R. Povolotsky, May 01 2012
The union of the sequences A214555, A214556, A214557, A214558, A214559 and the element 0 gives the sequence A099009. - Syed Iddi Hasan, Jul 24 2012
The comment made by Jens Kruse Andersen is missing one more family of terms (which starts with one or more digits "9" and ends with the digit "1"): 97508421, 9753086421, 9975084201, 975330866421, 997530864201, 999750842001, ... This family could be generalized (using the same method as in Andersen's comment) and it is actually covered by Syed Iddi Hasan in A214559. Also A214557 and A214558 (both - by Syed Iddi Hasan) are variants of Andersen's 8643(n)1976(n)532. - Alexander R. Povolotsky, Mar 14 2015
Fixed points of A151949. - Reinhard Zumkeller, Mar 23 2015

Examples

			6174 is a fixed point of the mapping and hence a term: 6174 -> 7641 - 1467 = 6174.
		

Crossrefs

In other bases: A163205 (base 2), A164997 (base 3), A165016 (base 4), A165036 (base 5), A165055 (base 6), A165075 (base 7), A165094 (base 8), A165114 (base 9).

Programs

  • Haskell
    a099009 n = a099009_list !! (n-1)
    a099009_list = [x | x <- [0..], a151949 x == x]
    -- Reinhard Zumkeller, Mar 23 2015
    
  • Magma
    a:=func; [k:k in [0..10^7]|a(k)]; // Marius A. Burtea, Sep 12 2019
  • Mathematica
    f[n_] := Block[{d = IntegerDigits@ n, a, b}, a = FromDigits@ Sort@ d; b = FromDigits@ Reverse@ Sort@ d; n == b - a]; Select[Range@ 1000000, f] (* Michael De Vlieger, Mar 20 2015 *)
  • Python
    # (version 2.4) from Tim Peters
    def extend(base, start, n):
        if n == 0:
            yield base
            return
        for i in range(start, 10):
            for x in extend(base + str(i), i, n-1):
                yield x
    def drive(n):
        result = []
        for lo in extend("", 0, n):
            ilo = int(lo)
            if ilo == 0 and n > 1:
                continue
            hi = lo[::-1]
            diff = str(int(hi) - ilo)
            diff = "0" * (n - len(diff)) + diff
            if sorted(diff) == list(lo):
                result.append(diff)
        return sorted(result)
    for n in range(1, 17):
        # print("Length", n)
        # print('-' * 40)
        for r in drive(n):
            print(r, end=', ')
    

Extensions

More terms from Jens Kruse Andersen and Tim Peters (tim(AT)python.org), Oct 04 2004
Corrected by Jens Kruse Andersen, Oct 25 2004

A099010 Consider the Kaprekar map n->K(n) defined in A151949. Sequence gives numbers belonging to cycles of length greater than 1.

Original entry on oeis.org

53955, 59994, 61974, 62964, 63954, 71973, 74943, 75933, 82962, 83952, 420876, 642654, 750843, 840852, 851742, 860832, 862632, 7509843, 7519743, 7619733, 8429652, 8439552, 8649432, 8719722, 9529641, 43208766, 64308654, 64326654
Offset: 1

Views

Author

Klaus Brockhaus, Sep 22 2004

Keywords

Comments

86526432, 64308654, 83208762 form a cycle of length three and 86308632, 86326632, 64326654, 43208766, 85317642, 75308643, 84308652 form a cycle of length seven.

Examples

			53955 and 59994 form a cycle of length 2 and hence are terms: 53955 -> 95553 - 35559 = 59994 -> 99954 - 45999 = 53955.
		

Crossrefs

Cf. A164715 (corresponding cycle lengths) [From Joseph Myers, Aug 24 2009]
In other bases: Empty (base 2), A165000 (base 3), A165019 (base 4), A165039 (base 5), A165058 (base 6), A165078 (base 7), A165097 (base 8), A165117 (base 9). [From Joseph Myers, Sep 05 2009]

Extensions

Definition revised ny N. J. A. Sloane, Aug 18 2009
Extended by Joseph Myers, Aug 22 2009

A160761 The Kaprekar binary numbers in decimal.

Original entry on oeis.org

9, 9, 9, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 45, 45, 49, 45, 49, 49, 45, 45, 49, 49, 45, 49, 45, 45, 45, 49, 49, 45, 49, 45, 45, 49, 45, 45, 45, 93, 93, 105, 93, 105, 105, 105, 93, 105, 105, 105, 105, 105, 105, 93, 93, 105, 105, 105, 105, 105, 105, 93, 105, 105, 105
Offset: 1

Views

Author

Damir Olejar, May 25 2009

Keywords

Examples

			The number 9 is 1001 in binary. The maximum number using the same number of 0's and one's is found and the minimum number having the same number of 0's and 1's is found to obtain the equation such as 1100 - 0011 = 1001. Repeating the same procedure always gives us the same number and pattern of 0's and 1's. Therefore 9 is one of the Kaprekar numbers. Numbers that end the procedure in 0 are excluded since they are not Kaprekar numbers.
		

References

  • M. Charosh, Some Applications of Casting Out 999...'s, Journal of Recreational Mathematics 14, 1981-82, pp. 111-118
  • D. R. Kaprekar, On Kaprekar numbers, J. Rec. Math., 13 (1980-1981), 81-82.

Crossrefs

Programs

  • Java
    class pattern { public static void main(String args[]) { int mem1 = 0; int mem2 =1; for (int i = 1; i<3000; i++) {do { mem1 = mem2; String binaryi = Integer.toBinaryString(i); String binarysort = ""; String binaryminimum = ""; for (int n = 0; n< binaryi.length(); n++) { String g = binaryi.substring(n,n+1); if (g.equals("0")){ binarysort = binarysort+"0"; } else { binarysort = "1"+binarysort; binaryminimum = binaryminimum + "1"; } } int binrev1 = Integer.parseInt(binarysort , 2); int binrev2 = Integer.parseInt(binaryminimum , 2); int diff = binrev1 - binrev2; mem2 = diff; } while (mem2!=0 && mem2!=mem1); String memtobin = Integer.toBinaryString(mem1); int ones = 0; for (int t = 0; t
    				
  • Mathematica
    nmax = 100; f[n_] := Module[{id, sid, min, max}, id = IntegerDigits[n, 2]; min = FromDigits[sid = Sort[id], 2]; max = FromDigits[Reverse[sid], 2]; max - min]; Reap[Do[If[(fpn = FixedPoint[f, n]) > 0, Sow[fpn]], {n, 1, nmax}]][[2, 1]] (* Jean-François Alcover, Apr 23 2017 *)

Formula

1. Sort all integers from the number in descending order 2. Sort all integers from the number in ascending order 3. Subtract ascending from descending order to obtain a new number 4. Repeat the steps 1-3 with a new number until a repetitive sequence is obtained or until a zero is obtained. 5. Call the repetitive sequence's number a Kaprekar number, ignore zeros.

A177686 If a1a2a3 is a 3-digit integer in a concatenated form, we define two permutations of its digits as follows: P1(a1a2a3)=a2a3a1 and P2(a1a2a3)=a1a3a2, then we take the absolute value of their difference. Thus we form a sequence: a1a2a3, abs(P1(a1a2a3)-P2(a1a2a3)), and so on.

Original entry on oeis.org

99, 891, 198, 792, 297, 693, 396, 594, 495
Offset: 1

Views

Author

F. Smarandache (smarand(AT)unm.edu), May 10 2010

Keywords

Comments

This is an alternative to Kaprekar's routine. It would be interested in studying 4-digit integers with the permutations P1(a1a2a3a4)=a2a3a4a1 and P2(a1a2a3a4)=a1a3a4a2. Other permutations can be also studied. A generalization of Kaprekar's routine is the following: Let f be an operator that maps a finite set A={a1, a2, ..., a_p}, with p>=1 elements, into itself. Then, for any value 'a' in A, we have f(a) belongs to A too. If we iterate this operator multiple times, we get a chain: a, f(a), f(f(a)), ..., f(f...f(a)...), ... all of whose elements are in A. But, since A is finite, after at most p iterations we get two equal iterations. Therefore we end up in a finite cycle (of one or more terms).

Examples

			Starting with 100, we get abs(001-100)=099, then abs(990-099)=891, then abs(918-819)=099, etc. So 100, 099, 891, 099, ... (the cycle is 099, 891). Each three-digit number ends up in a cycle of two terms (such as: 99 and 891, or 198 and 792, or 297 and 693, or 396 and 594), or in a constant 495 (as in Kaprekar's routine).
Starting with 495, we get abs(954-459)=495 (cycle of one term).
		

Crossrefs

Formula

abs(P1(a1a2a3)-P2(a1a2a3)) = abs(a2a3a1-a1a3a2) = 99x(a2-a1).

Extensions

Added keyword:base,fini,full as there are only 9 different values obtained by the abs() starting from any a1a2a3 in the range 100 to 999 R. J. Mathar, May 15 2010
Showing 1-4 of 4 results.