login
Smallest k such that 9^k has exactly n 7's in its decimal representation.
0

%I #8 Nov 02 2019 16:34:51

%S 1,3,14,19,24,34,25,50,64,45,87,56,92,86,112,150,84,73,142,140,162,

%T 165,147,196,207,195,211,278,187,172,224,234,258,254,268,291,287,249,

%U 342,306,331,339,361,309,396,439,343,391,413,397,533

%N Smallest k such that 9^k has exactly n 7's in its decimal representation.

%t a = {}; Do[k = 1; While[ Count[ IntegerDigits[9^k], 7] != n, k++ ]; a = Append[a, k], {n, 0, 50} ]; a

%t Module[{nn=600,nk},nk=Table[{n,DigitCount[9^n,10,7]},{n,nn}];Table[ SelectFirst[ nk,#[[2]]==k&],{k,0,50}]][[All,1]] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Nov 02 2019 *)

%K base,nonn

%O 0,2

%A _Robert G. Wilson v_, Aug 10 2001

%E Name corrected by _Jon E. Schoenfield_, Jun 26 2018