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.

A037904 Greatest digit of n - least digit of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 9
Offset: 1

Views

Author

Keywords

Comments

a(n) = A054055(n)-A054054(n); a(A010785(n)) = 0; for k>0: a(n) = a(n*10^k + A000030(n)) = a(n*10^k + A010879(n)) = a(n*10^k + A054054(n)) = a(n*10^k + A054055(n)) . - Reinhard Zumkeller, Dec 14 2007; corrected by David Wasserman, May 21 2008

Crossrefs

Programs

  • Haskell
    a037904 = f 9 0 where
       f u v 0 = v - u
       f u v z = f (min u d) (max v d) z' where (z', d) = divMod z 10
    -- Reinhard Zumkeller, Dec 16 2013
    
  • Maple
    f:= n -> (max-min)(convert(n,base,10)):
    map(f, [$1..1000]); # Robert Israel, Jul 07 2016
  • Mathematica
    f[n_] := Block[{d = IntegerDigits[n]}, Max[d] - Min[d]]; Table[ f[n], {n, 1, 15}]
  • PARI
    a(n)=my(d=digits(n)); vecmax(d)-vecmin(d) \\ Charles R Greathouse IV, Feb 07 2017
    
  • Python
    def A037904(n): return int(max(s:=str(n)))-int(min(s)) # Chai Wah Wu, Nov 10 2023

Extensions

Incorrect comments deleted by Robert Israel, Jul 07 2016