Smallest power of 6 whose decimal expansion contains n: Difference between revisions

→‎{{header|Raku}}: Add a Raku example
(→‎{{header|Raku}}: Add a Raku example)
Line 165:
21 216 = 6^3
</pre>
 
=={{header|Raku}}==
 
<lang perl6>use Lingua::EN::Numbers;
 
sub super ($n) { $n.trans(<0 1 2 3 4 5 6 7 8 9> => <⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹>) }
 
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
};</lang>
 
<pre> 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</pre>
 
=={{header|REXX}}==
10,327

edits