Smallest power of 6 whose decimal expansion contains n

From Rosetta Code
Revision as of 05:39, 7 April 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task: Smallest power of 6 whose decimal expansion contains n, where '''n < 22''' <br><br> =={{header|Ring}}== <lang ring> load "stdlib.ring" decimals(0) see...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Smallest power of 6 whose decimal expansion contains n is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task

Smallest power of 6 whose decimal expansion contains n, where n < 22

Ring

<lang ring> load "stdlib.ring"

decimals(0) see "working..." + nl see "Smallest power of 6 whose decimal expansion contains n:" + nl

num = 0 limit = 200

for n = 1 to 21

   strn = string(n)
   for m = 0 to limit
       strpow = string(pow(6,m))
       ind = substr(strpow,strn)
       if ind > 0
          see "" + n + ". " + strpow + nl 
          exit
       ok
   next

next

see "done..." + nl </lang>

Output:
working...
Smallest power of 6 whose decimal expansion contains n:
1. 1
2. 216
3. 36
4. 46656
5. 46656
6. 6
7. 7776
8. 2176782336
9. 1296
10. 10077696
11. 2821109907456
12. 1296
13. 13060694016
14. 6140942214464815497216
15. 101559956668416
16. 216
17. 60466176
18. 470184984576
19. 21936950640377856
20. 170581728179578208256
21. 216
done...