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

(Smallest power of 6 whose decimal expansion contains n en FreeBASIC)
Line 620:
20: 170581728179578208256
21: 216</pre>
 
=={{header|jq}}==
'''Works with gojq, the Go implementation of jq'''
 
gojq provides unbounded-precision integer arithmetic and is therefore appropriate for this task.
<lang jq># To preserve precision:
def power($b): . as $in | reduce range(0;$b) as $i (1; . * $in);
 
range(0;22)
| . as $in
| tostring as $n
| first(range(0;infinite) as $i | 6 | power($i) | . as $p | tostring | (index($n) // empty)
| [$in,$i,$p] )</lang>
{{out}}
<pre>
[0,9,10077696]
[1,0,1]
[2,3,216]
[3,2,36]
[4,6,46656]
[5,6,46656]
[6,1,6]
[7,5,7776]
[8,12,2176782336]
[9,4,1296]
[10,9,10077696]
[11,16,2821109907456]
[12,4,1296]
[13,13,13060694016]
[14,28,6140942214464815497216]
[15,18,101559956668416]
[16,3,216]
[17,10,60466176]
[18,15,470184984576]
[19,21,21936950640377856]
[20,26,170581728179578208256]
[21,3,216]
</pre>
 
 
=={{header|Julia}}==
2,461

edits