Smallest numbers
Smallest numbers 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 number k > 0 such that the decimal expansion of k^k contains n, where n < 51
Ring
<lang ring> load "stdlib.ring"
decimals(0) see "working..." + nl see "Smallest number k > 0 such that the decimal expansion of k^k contains n are:" + nl
row = 0 limit1 = 49 limit2 = 30
for n = 0 to limit1
strn = string(n) for m = 1 to limit2 powm = pow(m,m) strm = string(powm) ind = substr(strm,strn) if ind > 0 exit ok next row = row + 1 see "" + m + " " if row%10 = 0 see nl ok
next
see "done..." + nl </lang>
- Output:
working... Smallest number k > 0 such that the decimal expansion of k^k contains n are: 9 1 3 5 2 4 4 3 7 9 10 11 5 19 21 18 8 25 16 19 9 8 13 7 17 4 17 3 11 18 13 5 19 17 18 7 17 15 9 15 16 18 9 7 12 25 6 23 9 23 done...