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

Add Factor
mNo edit summary
(Add Factor)
Line 5:
<br><br>
 
 
 
=={{header|Factor}}==
{{works with|Factor|0.99 2021-02-05}}
<lang factor>USING: formatting kernel lists lists.lazy math math.functions
present sequences tools.memory.private ;
 
: powers-of-6 ( -- list )
0 lfrom [ 6 swap ^ ] lmap-lazy ;
 
: smallest ( m -- n )
powers-of-6 [ [ present ] bi@ subseq? ] with lfilter car ;
 
22 [ dup smallest commas "%2d %s\n" printf ] each-integer</lang>
{{out}}
<pre>
0 10,077,696
1 1
2 216
3 36
4 46,656
5 46,656
6 6
7 7,776
8 2,176,782,336
9 1,296
10 10,077,696
11 2,821,109,907,456
12 1,296
13 13,060,694,016
14 6,140,942,214,464,815,497,216
15 101,559,956,668,416
16 216
17 60,466,176
18 470,184,984,576
19 21,936,950,640,377,856
20 170,581,728,179,578,208,256
21 216
</pre>
 
=={{header|Julia}}==
1,808

edits