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.
%I A006942 M4049 #78 Jun 02 2021 08:01:47 %S A006942 6,2,5,5,4,5,6,3,7,6,8,4,7,7,6,7,8,5,9,8,11,7,10,10,9,10,11,8,12,11, %T A006942 11,7,10,10,9,10,11,8,12,11,10,6,9,9,8,9,10,7,11,10,11,7,10,10,9,10, %U A006942 11,8,12,11,12,8,11,11,10,11,12,9,13,12,9,5,8,8,7,8,9 %N A006942 Number of segments used to represent n on calculator display, variant 5: digits '6', '7' and '9' use 6, 3 and 6 segments, respectively. %C A006942 a(A216261(n)) = n and a(m) <> n for m < A216261(n). - _Reinhard Zumkeller_, Mar 15 2013 %C A006942 If we mark with * resp. ' the graphical representations which use more resp. less segments, we have the following variants: %C A006942 A063720 (6', 7', 9'), A277116 (6*, 7', 9'), A074458 (6*, 7*, 9'), %C A006942 _______________ this: A006942 (6*, 7', 9*), A010371 (6*, 7*, 9*). %C A006942 Sequences A234691, A234692 and variants make precise which segments are lit in each digit. These are related through the Hamming weight function A000120, e.g., A010371(n) = A000120(A234691(n)) = A000120(A234692(n)). - _M. F. Hasler_, Jun 17 2020 %D A006942 Clifford A. Pickover, A Passion for Mathematics, Wiley, 2005; see p. 65. %D A006942 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence). %H A006942 Nathaniel Johnston, <a href="/A006942/b006942.txt">Table of n, a(n) for n = 0..10000</a> %H A006942 Netnews group rec.puzzles, Frequently Asked Questions (FAQ) file, <a href="http://www.faqs.org/faqs/puzzles/archive/Instructions/">Instructions</a> problem series.31, and <a href="http://www.faqs.org/faqs/puzzles/archive/series/">Series Section</a> solution series.31. %H A006942 <a href="/index/Ca#calculatordisplay">Index entries for sequences related to calculator display</a> %F A006942 a(n) = a(floor(n/10)) + a(n mod 10) for n > 9. - _Reinhard Zumkeller_, Mar 15 2013 %F A006942 a(n) = A010371(n) - A102679(n) + A102681(n) (subtract the number of digits 7 in n) = A277116(n) + A102683(n) (add number of digits 9 in n); and in particular, A063720(n) <= A277116(n) <= a(n) = A010371(n). - _M. F. Hasler_, Jun 17 2020 %e A006942 As depicted below, zero uses 6 segments, so a(0)=6. %e A006942 _ _ _ _ _ _ _ _ %e A006942 | | | _| _| |_| |_ |_ | |_| |_| %e A006942 |_| | |_ _| | _| |_| | |_| _| %e A006942 . %e A006942 [Edited by _Jon E. Schoenfield_, Jul 30 2017] %p A006942 A006942 := proc(n) local d,dig,j,s: if(n=0)then return 6:fi: dig:=[6,2,5,5,4,5,6,3,7,6]: d:=convert(n,base,10): s:=0: for j from 1 to nops(d) do s:=s+dig[d[j]+1]: od: return s: end: seq(A006942(n),n=0..100); # _Nathaniel Johnston_, May 08 2011 %t A006942 MapIndexed[ (f[First[#2] - 1] = #1)& , {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}]; a[n_] := Plus @@ f /@ IntegerDigits[n]; Table[a[n], {n, 0, 76}] (* _Jean-François Alcover_, Sep 25 2012 *) %t A006942 a[n_] := Plus @@ (IntegerDigits@ n /. {0 -> 6, 1 -> 2, 2 -> 5, 3 -> 5, 7 -> 3, 8 -> 7, 9 -> 6}); Array[a, 77, 0] (* _Robert G. Wilson v_, Jun 20 2018 *) %o A006942 (Haskell) %o A006942 a006942 n = a006942_list !! n %o A006942 a006942_list = [6,2,5,5,4,5,6,3,7,6] ++ f 10 where %o A006942 f x = (a006942 x' + a006942 d) : f (x + 1) %o A006942 where (x',d) = divMod x 10 %o A006942 -- _Reinhard Zumkeller_, Mar 15 2013 %o A006942 (PARI) a(n)=if(n==0, return(6)); my(d=digits(n),v=vector(10)); for(i=1,#d, v[d[i]+1]++); v*[6, 2, 5, 5, 4, 5, 6, 3, 7, 6]~ \\ _Charles R Greathouse IV_, Feb 05 2018 %o A006942 (Python) %o A006942 def a(n): return sum([6, 2, 5, 5, 4, 5, 6, 3, 7, 6][int(d)] for d in str(n)) %o A006942 print([a(n) for n in range(77)]) # _Michael S. Branicky_, Jun 02 2021 %Y A006942 Cf. A216261 (least inverse), A165244 (sorted digits), A302552 (primes), A328330 (iterations), A331529 (histogram). %Y A006942 Variants are A010371, A063720, A074458, A277116, see comments. %Y A006942 See also A234691, A234692, A000120. %K A006942 base,nonn,nice,easy %O A006942 0,1 %A A006942 _N. J. A. Sloane_ %E A006942 More terms from _Matthew Conroy_, Sep 13 2001