Base 16 numbers needing a to f: Difference between revisions
→{{header|Factor}}: Add an eager solution
(→{{header|Factor}}: Add an eager solution) |
|||
Line 1,241:
301 such numbers found.
</pre>
The above solution uses lazy computation and tail recursion. Here's an eager solution, but it allocates a lot of intermediate sequences.
<syntaxhighlight lang="factor">USING: formatting kernel math ranges sequences ;
IN: rosetta-code.needs-a..f?
: quads ( n -- seq )
[ dup 0 > ] [ 16 /mod ] produce nip ;
: needs-a..f? ( n -- ? )
quads [ 9 > ] any? ;
500 [1..b] [ needs-a..f? ] filter [ "%d " printf ] each</syntaxhighlight>
{{out}}Same numbers as above, but on a single line.
=={{header|FOCAL}}==
|