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

A193582 Persistence of n for sort-and-subtract (A193581).

Original entry on oeis.org

0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 3, 3, 3, 2, 2, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Aug 10 2011

Keywords

Comments

Number of sort-and-subtract steps to reach 0 when starting with n.

Crossrefs

Cf. A004185.

Programs

  • Haskell
    a193582 n = length $ takeWhile (> 0) $ iterate a193581 n
    a193582_list = map a193582 [0..]

A009994 Numbers with digits in nondecreasing order.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 33, 34, 35, 36, 37, 38, 39, 44, 45, 46, 47, 48, 49, 55, 56, 57, 58, 59, 66, 67, 68, 69, 77, 78, 79, 88, 89, 99, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122
Offset: 1

Views

Author

Keywords

Comments

Record values and occurrences of A004185. - Reinhard Zumkeller, Dec 05 2009
A193581(a(n)) = 0. - Reinhard Zumkeller, Aug 10 2011
This sequence was used by the U.S. Bureau of the Census in the mid-1950s to numerically code the alphabetical list of counties within a state (with some modifications for Texas). The 3-digit code has a "self-policing element" built into it and "was fairly effective in detecting the transposition of 2 digits." (Hanna 1959). - Randy A. Becker, Dec 11 2017

References

  • Amarnath Murthy and Robert J. Clarke, Some Properties of Staircase sequence, Mathematics & Informatics Quarterly, Volume 11, No. 4, November 2001.
  • Frank A. Hanna, The Compilation of Manufacturing Statistics. U.S. Department of Commerce, Bureau of the Census, 1959.

Crossrefs

Apart from the first term, a subsequence of A052382. A254143 is a subsequence.

Programs

  • Haskell
    import Data.Set (fromList, deleteFindMin, insert)
    a009994 n = a009994_list !! n
    a009994_list = 0 : f (fromList [1..9]) where
       f s = m : f (foldl (flip insert) s' $ map (10*m +) [m `mod` 10 ..9])
             where (m,s') = deleteFindMin s
    -- Reinhard Zumkeller, Aug 10 2011
    
  • Magma
    [k:k in [0..122]|Sort(Intseq(k)) eq Reverse(Intseq(k))]; // Marius A. Burtea, Jul 28 2019
    
  • Maple
    A[0]:= [0]: A[1]:= [$1..9]:
    for d from 2 to 4 do
      A[d]:= map(t -> seq(10*t+i,i=(t mod 10) .. 9), A[d-1]):
    od:
    seq(op(A[d]),d=0..4); # Robert Israel, Jul 28 2019
  • Mathematica
    Select[Range[0, 125], LessEqual@@IntegerDigits[#] &] (* Ray Chandler, Oct 25 2011 *)
  • PARI
    is(n)=n=digits(n);n==vecsort(n) \\ Charles R Greathouse IV, Dec 03 2013
    
  • Python
    from itertools import combinations_with_replacement
    def A009994generator():
        yield 0
        l = 1
        while True:
            for i in combinations_with_replacement('123456789',l):
                yield int(''.join(i))
            l += 1 # Chai Wah Wu, Nov 11 2015
    
  • Scala
    def hasDigitsSorted(n: Int): Boolean = {
      val digSort = Integer.parseInt(n.toString.toCharArray.sorted.mkString)
      n == digSort
    }
    (0 to 200).filter(hasDigitsSorted()) // _Alonso del Arte, Apr 20 2020

Formula

a(n) >> exp(n^(1/10)). - Charles R Greathouse IV, Mar 15 2014
a(n) ~ 10^((9! n)^(1/9) - 5), since 10^(d - 1) <= a(n) < 10^d for binomial(d + 8, 9) < n <= binomial(d + 9, 9) = (d + 5 - epsilon)^9 / 9!. Using epsilon = 10/(3n) + o(1/n) gives more precise estimate. [Following Radcliffe and McKay, cf. SeqFan list.] - M. F. Hasler, Jul 30 2019

A004185 Arrange digits of n in increasing order, then (for n > 0) omit the zeros.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 12, 22, 23, 24, 25, 26, 27, 28, 29, 3, 13, 23, 33, 34, 35, 36, 37, 38, 39, 4, 14, 24, 34, 44, 45, 46, 47, 48, 49, 5, 15, 25, 35, 45, 55, 56, 57, 58, 59, 6, 16, 26, 36, 46, 56, 66, 67, 68, 69, 7, 17, 27, 37, 47
Offset: 0

Views

Author

Keywords

Comments

Record values: A009994. - Reinhard Zumkeller, Dec 05 2009
If we define "sortable primes" as prime numbers that remain prime when their digits are sorted in increasing order, then all absolute primes (A003459) are sortable primes but not all sortable primes are absolute primes. For example, 311 is both sortable and absolute, and 271 is sortable but not absolute, since its digits can be permuted to 217 = 7 * 31 or 712 = 2^3 * 89, etc. - Alonso del Arte, Oct 05 2013
The above mentioned "sortable primes" are listed in A211654, the nontrivial ones (with digits not in nondecreasing order) in A086042. - M. F. Hasler, Jul 30 2019

Examples

			a(19) = 19 because the digits are already in increasing order.
a(20) = 2 because the digits of 20 are 2 and 0, which in increasing order are 0 and 2, but since zero-padding is not allowed on the left, the zero digit is dropped and we are left with 2.
a(21) = 12 because the digits of 21 are 2 and 1, which in increasing order are 1 and 2.
		

Crossrefs

Cf. A211654 (sortable primes) and subsequence A086042 (nontrivial solutions).

Programs

  • Haskell
    import Data.List (sort)
    a004185 n = read $ sort $ show n :: Integer
    -- Reinhard Zumkeller, Aug 10 2011
    
  • Magma
    A004185:=func; [n eq 0 select 0 else A004185(n): n in [0..57]]; // Bruno Berselli, Apr 03 2012
    
  • Maple
    A004185 := proc(n)
        local dgs;
        convert(n,base,10) ;
        dgs := sort(%,`>`) ;
        add( op(i,dgs)*10^(i-1),i=1..nops(dgs)) ;
    end proc:
    seq(A004185(n),n=0..20) ; # R. J. Mathar, Jul 26 2015
  • Mathematica
    FromDigits[Sort[DeleteCases[IntegerDigits[#], 0]]]&/@Range[0, 60] (* Harvey P. Dale, Nov 29 2011 *)
  • PARI
    a(n)=fromdigits(vecsort(digits(n))) \\ Charles R Greathouse IV, Feb 06 2017
  • Python
    def A004185(n):
        return int(''.join(sorted(str(n))).replace('0','')) if n > 0 else 0 # Chai Wah Wu, Nov 10 2015
    

A009995 Numbers with digits in strictly decreasing order. From the Macaulay expansion of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 21, 30, 31, 32, 40, 41, 42, 43, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64, 65, 70, 71, 72, 73, 74, 75, 76, 80, 81, 82, 83, 84, 85, 86, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98, 210, 310, 320, 321, 410, 420, 421, 430, 431, 432, 510, 520, 521, 530
Offset: 1

Views

Author

Keywords

Comments

There are precisely 1023 terms (corresponding to every nonempty subset of {0..9}).
A178788(a(n)) = 1. - Reinhard Zumkeller, Jun 30 2010
A193581(a(n)) > 0 for n > 9. - Reinhard Zumkeller, Aug 10 2011
A227362(a(n)) = a(n). - Reinhard Zumkeller, Jul 09 2013
For a fixed natural number r, any natural number n has a unique "Macaulay expansion" n = C(a_r,r)+C(a_{r-1},r-1)+...+C(a_1,1) with a_r > a_{r-1} > ... > a_1 >= 0. If r=10, concatenating the digits a_r, ..., a_1 gives the present sequence. The representation is valid for all n, but the concatenation only makes sense if all the a_i are < 10. - N. J. A. Sloane, Apr 05 2014
a(n) = A262557(A263327(n)); a(A263328(n)) = A262557(n). - Reinhard Zumkeller, Oct 15 2015

Crossrefs

Cf. A009993.
Cf. A262557 (sorted lexicographically), A263327, A263328.

Programs

  • Haskell
    import Data.Set (fromList, minView, insert)
    a009995 n = a009995_list !! n
    a009995_list = 0 : f (fromList [1..9]) where
       f s = case minView s of
             Nothing     -> []
             Just (m,s') -> m : f (foldl (flip insert) s' $
                                  map (10*m +) [0..m `mod` 10 - 1])
    -- Reinhard Zumkeller, Aug 10 2011
    
  • Mathematica
    Sort@ Flatten@ Table[FromDigits /@ Subsets[ Range[9, 0, -1], {n}], {n, 10}] (* Zak Seidov, May 10 2006 *)
  • PARI
    is(n)=fromdigits(vecsort(digits(n),,12))==n \\ Charles R Greathouse IV, Apr 16 2015

A108782 Difference between n and the largest number with the same digit set as n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 18, 27, 36, 45, 54, 63, 72, 0, 0, 0, 9, 18, 27, 36, 45, 54, 63, 0, 0, 0, 0, 9, 18, 27, 36, 45, 54, 0, 0, 0, 0, 0, 9, 18, 27, 36, 45, 0, 0, 0, 0, 0, 0, 9, 18, 27, 36, 0, 0, 0, 0, 0, 0, 0, 9, 18, 27, 0, 0, 0, 0, 0, 0, 0, 0, 9, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0
Offset: 0

Views

Author

Zak Seidov, Jun 29 2005

Keywords

Crossrefs

Programs

  • Mathematica
    FromDigits[Sort[IntegerDigits[n], Greater]] - n (Rob Pratt)
    Table[Max[FromDigits/@ Permutations[IntegerDigits[n]]]-n, {n, 150}]

Formula

a(n) = A004186(n) - n. - Seiichi Manyama, Sep 25 2018

Extensions

a(0)=0 prepended by Seiichi Manyama, Sep 25 2018
Showing 1-5 of 5 results.