Brilliant numbers: Difference between revisions

Content deleted Content added
Thundergnat (talk | contribs)
m →‎{{header|Raku}}: better grammar
Thundergnat (talk | contribs)
m →‎{{header|Raku}}: Formatting / layout tweaks
Line 42: Line 42:
};
};


# The task
# Testing
put "First 100 brilliant numbers:\n" ~ @brilliant[^100].batch(10)».fmt("%4d").join("\n") ~ "\n" ;
put "First 100 brilliant numbers:\n" ~ @brilliant[^100].batch(10)».fmt("%4d").join("\n") ~ "\n" ;


for 1 .. 7 -> $e {
for 1 .. 7 -> $oom {
my $threshold = exp $e, 10;
my $threshold = exp $oom, 10;
my $key = @brilliant.first: :k, * >= exp $e, 10;
my $key = @brilliant.first: :k, * >= $threshold;
say "First term >= {comma $threshold} is {ordinal-digit 1 + $key} in the series: {comma @brilliant[$key]}";
printf "First >= %13s is %9s in the series: %13s\n", comma($threshold), ordinal-digit(1 + $key, :u), comma @brilliant[$key];
}</lang>
}</lang>
{{out}}
{{out}}
Line 63: Line 63:
1247 1261 1271 1273 1333 1343 1349 1357 1363 1369
1247 1261 1271 1273 1333 1343 1349 1357 1363 1369


First term >= 10 is 4th in the series: 10
First >= 10 is 4ᵗʰ in the series: 10
First term >= 100 is 11th in the series: 121
First >= 100 is 11ᵗʰ in the series: 121
First term >= 1,000 is 74th in the series: 1,003
First >= 1,000 is 74ᵗʰ in the series: 1,003
First term >= 10,000 is 242nd in the series: 10,201
First >= 10,000 is 242ⁿᵈ in the series: 10,201
First term >= 100,000 is 2505th in the series: 100,013
First >= 100,000 is 2505ᵗʰ in the series: 100,013
First term >= 1,000,000 is 10538th in the series: 1,018,081
First >= 1,000,000 is 10538ᵗʰ in the series: 1,018,081
First term >= 10,000,000 is 124364th in the series: 10,000,043
First >= 10,000,000 is 124364ᵗʰ in the series: 10,000,043
First term >= 100,000,000 is 573929th in the series: 100,140,049
First >= 100,000,000 is 573929ᵗʰ in the series: 100,140,049
First term >= 1,000,000,000 is 7407841st in the series: 1,000,000,081</pre>
First >= 1,000,000,000 is 7407841ˢᵗ in the series: 1,000,000,081</pre>