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.

A107846 Number of duplicate digits of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0
Offset: 0

Views

Author

Rick L. Shepherd, May 24 2005

Keywords

Comments

a(A010784(n)) = 0; a(A109303(n)) > 0. - Reinhard Zumkeller, Jul 09 2013

Examples

			a(11) = 1 because 11 has two total decimal digits but only one distinct digit (1) and 2-1=1.
Similarly, a(3653135) = 7 (total digits) - 4 (distinct digits: 1,3,5,6) = 3 (There are three duplicate digits here, namely, 3, 3 and 5).
		

Crossrefs

Cf. A055642 (Total decimal digits of n), A043537 (Distinct decimal digits of n).

Programs

  • Haskell
    import Data.List (sort, group)
    a107846 = length . concatMap tail . group . sort . show :: Integer -> Int
    -- Reinhard Zumkeller, Jul 09 2013
    
  • Mathematica
    Table[Total[Select[DigitCount[n]-1,#>0&]],{n,0,120}] (* Harvey P. Dale, Jul 31 2013 *)
  • Python
    def a(n): return len(s:=str(n)) - len(set(s))
    print([a(n) for n in range(105)]) # Michael S. Branicky, Jan 09 2023

Formula

a(n) = A055642(n) - A043537(n).