Smallest power of 6 whose decimal expansion contains n

use Lingua::EN::Numbers;

my @po6 = ^Inf .map: *.exp: 6;

put join "\n", (flat ^22, 120).map: -> $n {
    sprintf "%3d: 6%-4s %s", $n, .&super, comma @po6[$_]
    given @po6.first: *.contains($n), :k
};

Output:

  0: 6⁹    10,077,696
  1: 6⁰    1
  2: 6³    216
  3: 6²    36
  4: 6⁶    46,656
  5: 6⁶    46,656
  6: 6¹    6
  7: 6⁵    7,776
  8: 6¹²   2,176,782,336
  9: 6⁴    1,296
 10: 6⁹    10,077,696
 11: 6¹⁶   2,821,109,907,456
 12: 6⁴    1,296
 13: 6¹³   13,060,694,016
 14: 6²⁸   6,140,942,214,464,815,497,216
 15: 6¹⁸   101,559,956,668,416
 16: 6³    216
 17: 6¹⁰   60,466,176
 18: 6¹⁵   470,184,984,576
 19: 6²¹   21,936,950,640,377,856
 20: 6²⁶   170,581,728,179,578,208,256
 21: 6³    216
120: 6¹⁴⁷  2,444,746,349,972,956,194,083,608,044,935,243,159,422,957,210,683,702,349,648,543,934,214,737,968,217,920,868,940,091,707,112,078,529,114,392,164,827,136

Last updated