Smallest numbers: Difference between revisions

(added pascal)
Line 522:
50 │ 23
─────┴───────────────────────────────────────────────────────────────────────────
</pre>
 
=={{header|Ring}}==
<lang ring>
//load "stdlib.ring"
load "bignumber.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 = 50
limit2 = 30
for n = 0 to limit1
strn = string(n)
for m = 1 to limit2
powm = pow(m,m)
ind = substr(powm,strn)
if ind > 0
exit
ok
next
row = row + 1
see "" + m + " "
if row%10 = 0
see nl
ok
next
 
see nl + "done..." + nl
 
func pow(num1,num2)
num1 = string(num1)
num2 = string(num2)
return FuncPower(num1,num2)
</lang>
{{out}}
<pre>
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 22 26 8 17 16 19
9 8 13 7 17 4 17 3 11 18
13 5 23 17 18 7 17 15 9 18
16 17 9 7 12 28 6 23 9 24
23
done...
</pre>
 
2,468

edits