login
Number of n-digit squares which contain the string "666" but not "6666".
0

%I #16 Mar 26 2021 15:00:28

%S 0,0,0,0,0,0,3,21,78,302,1139,4156,14791,52529,183565,635691,2183533,

%T 7314869,25303217

%N Number of n-digit squares which contain the string "666" but not "6666".

%t fQ[n_] := StringPosition[ ToString[n^2], "666"] != {} && StringPosition[ ToString[n^2], "6666"] == {}; t = Table[0, {20}]; Do[ If[ fQ[n], t[[ Ceiling[ Log[10, n^2]] + 1]]++ ], {n, 3162277661}]; t (* _Robert G. Wilson v_, Mar 10 2005 *)

%t t6[digs_]:=Module[{a=Floor[Sqrt[10^(digs-1)]],b=Floor[ Sqrt[ 10^digs]]},Count[ Range[a,b]^2,_?(SequenceCount[IntegerDigits[#],{6,6,6}]> 0&&SequenceCount[IntegerDigits[#],{6,6,6,6}]==0&)]]; Table[ t6[n],{n,20}] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Mar 26 2021 *)

%Y Cf. A052041, A075415, A102807 A032746.

%K nonn,base

%O 1,7

%A _James R. Buddenhagen_, Feb 27 2005

%E a(13)-a(19) from _Robert G. Wilson v_, Mar 03 2005