Numbers in base-16 representation that cannot be written with decimal digits: Difference between revisions

m
→‎{{header|Raku}}: trap some edge conditions I overlooked
m (→‎{{header|Wren}}: Iteration now starts at 1.)
m (→‎{{header|Raku}}: trap some edge conditions I overlooked)
Line 83:
#Generate such numbers directly, up to a threshold:
put "\nGenerate: first {+$_}:\n", .batch(10)».map({ "{$_}({:16($_)})" })».fmt('%9s').join("\n") given
((1..^Inf).grep(* % 7).map:( { .base(7).trans: [1..6] => ['A'..'F'] } )).grep(!*.contains: 0)[^42];
 
#Count such numbers directly, up to a threshold
my $upto = 500;
put "\nCount: " ~ [+] flat (map {exp($_, 6)}, 1..($upto.log(16).floor);</lang>),
+(exp($upto.log(16).floor, 16) .. $upto).grep( { so all |.map: { .polymod(16 xx *) »>» 9 } });</lang>
{{out}}
<pre>Filter: 42 such numbers:
10,333

edits