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.

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
    

A065641 Smallest number with persistence n for the sort-and-subtract-sequence.

Original entry on oeis.org

0, 1, 10, 60, 90, 101, 120, 380, 450, 505, 807, 1020, 1070, 1303, 1450, 3810, 10020, 10404, 10560, 16056, 16200, 18088, 20322, 20580, 35790, 79000, 80088, 90877, 243700, 279509, 330832, 374330, 380038, 903655, 1002404, 1005064, 1020828
Offset: 0

Views

Author

Ulrich Schimke (ulrschimke(AT)aol.com), Dec 03 2001

Keywords

Comments

Sort the digits of an integer and subtract the result from the original. Continue with the result until you reach 0. The sequence gives the least integer that needs n steps to reach 0.

Examples

			60 is the smallest number that needs 3 steps to reach 0: 60 -> 60 - 06 = 54 -> 54 - 45 = 9 -> 9 - 9 = 0, hence a(3) = 60.
		

Crossrefs

Programs

  • Haskell
    import Data.List (elemIndex)
    import Data.Maybe (fromJust)
    a065641 n = a065641_list !! (n-1)
    a065641_list = map (fromJust . (`elemIndex` a193582_list)) [1..]
    -- Reinhard Zumkeller,Aug 10 2011
  • Mathematica
    Persist[n_] := Length[NestWhileList[# - FromDigits[Sort[IntegerDigits[#]]] &, n, # != 0 &]] - 1; nn = 20; t = Table[0, {nn}]; cnt = 0; k = 0; While[cnt < nn, k++; c = Persist[k]; If[c <= nn && t[[c]] == 0, t[[c]] = k; cnt++]]; t  (* Harvey P. Dale, Mar 24 2011 *)
    persist[n_]:=Length[NestWhileList[#-FromDigits[Sort[IntegerDigits[#]]]&,n,#!=0&]]-1; Module[ {nn=103*10^4,tbl},tbl=Table[{n,persist[n]},{n,0,nn}];DeleteDuplicates[ tbl,GreaterEqual[ #1[[2]],#2[[2]]]&]][[;;,1]] (* Harvey P. Dale, Sep 03 2023 *)

Extensions

Added a(0) = 0. David W. Wilson, Jan 08 2017

A343639 a(n) = (Sum of digits of 9*n) / 9.

Original entry on oeis.org

0, 1, 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, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2
Offset: 0

Views

Author

M. F. Hasler, May 19 2021

Keywords

Comments

Similar to, but different from A193582, A326307, ...
Consider g = A008585 = multiply by 3, and its left inverse h = A002264, h o g = id (but g o h = id only on (the range of) A008585). In the spirit of group theory, we can write ad(g) = (x -> h o x o g), then A343638 = ad(A008585)(A007953) and this A343639 = ad(A008585)(A343638) = ad(A008585)^2 (A007953).

Crossrefs

Cf. A007953 (digit sum), A008591 (9n), A343638 (similar for 3), A083824 (9*n reversed and divided by 9), A279777 (a(n)=3).

Programs

  • Mathematica
    a[n_] := Plus @@ IntegerDigits[9*n]/9; Array[a, 100, 0] (* Amiram Eldar, May 19 2021 *)
  • PARI
    A343639(n)=sumdigits(9*n)/9

Formula

a(n) = A007953(A008591(n))/9, by definition. - Felix Fröhlich, May 19 2021
a(n) = A343638(3*n)/3 = A002264(A343638(A008585(n))), i.e., A343639 = A002264 o A343638 o A008585 (just as A343638 = A002264 o A007953 o A008585).
Showing 1-3 of 3 results.