Smallest numbers: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(5 intermediate revisions by 4 users not shown)
Line 801:
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
</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery">
[ stack ] is candidates ( --> s )
[ stack ] is results ( --> s )
 
[ [] swap times
[ i^ number$
nested join ]
candidates put
[] results put
0
[ 1+ dup
dup ** number$
candidates share
reverse witheach
[ over 2dup findseq
swap found iff
[ dip over
$->n drop
join nested
results take
join
results put
candidates take
i pluck drop
candidates put ]
else drop ]
drop
candidates share
[] = until ]
drop
candidates release
results take
sortwith
[ 1 peek swap 1 peek < ]
[] swap
witheach [ 0 peek join ] ] is task ( n --> [ )
 
51 task echo</syntaxhighlight>
 
{{out}}
 
<pre>[ 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 ]</pre>
 
=={{header|Raku}}==
<syntaxhighlight lang="raku" line>sub smallest ( $n ) {
Line 911 ⟶ 957:
23
done...
</pre>
 
=={{header|RPL}}==
{{works with|HP|49}}
« { }
0 50 '''FOR''' n
1
'''WHILE''' DUP DUP ^ →STR n →STR POS NOT
'''REPEAT''' 1 + '''END'''
+
'''NEXT'''
» '<span style="color:blue">TASK</span>' STO
{{out}}
<pre>
1: {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}
</pre>
 
=={{header|Ruby}}==
Using a hash as memo:
<syntaxhighlight lang="ruby">memo = Hash.new{|h, k| h[k] = (k**k).to_s }
res = (0..50).map{|n| (1..).detect{|m| memo[m].include? n.to_s} }
res.each_slice(10){|slice| puts "%4d"*slice.size % slice }
</syntaxhighlight>
{{out}}
<pre> 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
</pre>
 
Line 922 ⟶ 998:
=={{header|Wren}}==
{{libheader|Wren-big}}
{{libheader|Wren-seq}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./big" for BigInt
import "./seqfmt" for LstFmt
import "/fmt" for Fmt
 
var res = []
Line 941 ⟶ 1,015:
}
System.print("The smallest positive integers K where K ^ K contains N (0..50) are:")
for (chunk in Lst.chunks(res, 17)) Fmt.printtprint("$2d", chunkres, 17)</syntaxhighlight>
 
{{out}}
9,476

edits