[go: up one dir, main page]

login
Number of 7's in decimal expansion of prime(n).
10

%I #12 Oct 30 2023 09:52:24

%S 0,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,1,1,0,0,1,0,0,1,0,0,1,0,1,0,

%T 0,0,1,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,1,2,0,0,0,1,0,0,1,0,1,

%U 1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,1

%N Number of 7's in decimal expansion of prime(n).

%H Reinhard Zumkeller, <a href="/A085981/b085981.txt">Table of n, a(n) for n = 1..10000</a>

%t DigitCount[Prime[Range[100]],10,7] (* _Paolo Xausa_, Oct 30 2023 *)

%o (Haskell)

%o a085981 = count7 0 . a000040 where

%o count7 c x | d == 7 = if x < 10 then c + 1 else count7 (c + 1) x'

%o | otherwise = if x < 10 then c else count7 c x'

%o where (x', d) = divMod x 10

%o -- _Reinhard Zumkeller_, Apr 08 2014

%Y Cf. 0's A085974, 1's A085975, 2's A085976, 3's A085977, 4's A085978, 5's A085979, 6's A085980, 8's A085982, 9's A085983.

%K base,nonn

%O 1,59

%A _Jason Earls_, Jul 06 2003