Brilliant numbers: Difference between revisions

Added Quackery.
m (Fixed Swift syntax highlighting)
(Added Quackery.)
Line 1,055:
Above 10^16: 10000001400000049 at #13163230391313
Above 10^17: 100000000000000831 at #201431415980419</pre>
 
=={{header|Quackery}}==
 
<code>eratosthenes</code> and <code>isprime</code> are defined at [[Sieve of Eratosthenes#Quackery]].
 
<code>bsearchwith</code> is defined at [[Binary search#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ 1 swap
[ 10 / dup iff
[ dip 1+ ]
else done
again ]
drop ] is digits ( n --> n )
 
[ over size 0 swap 2swap
bsearchwith < drop ] is search ( [ n --> n )
 
1010 eratosthenes
1 temp put
[] [] []
1010 times
[ i^ isprime if
[ temp share
i^ digits < if
[ nested join
[]
1 temp tally ]
i^ join ] ]
nested join
temp release
witheach
[ dup witheach
[ over witheach
[ over *
dip rot join unrot ]
drop behead drop ]
drop ]
sort
say "First 100 brilliant numbers:" cr
dup 100 split drop
unbuild
2 split nip -2 split drop
nest$ 40 wrap$ cr cr
6 times
[ dup dup 10 i^ 1+ **
say "First > "
dup 1 - echo
say " is "
search tuck peek echo
say " at position " 1+ echo
say "." cr ]
drop</syntaxhighlight>
 
{{out}}
 
<pre>First 100 brilliant numbers:
 
4 6 9 10 14 15 21 25 35 49 121 143 169
187 209 221 247 253 289 299 319 323 341
361 377 391 403 407 437 451 473 481 493
517 527 529 533 551 559 583 589 611 629
649 667 671 689 697 703 713 731 737 767
779 781 793 799 803 817 841 851 869 871
893 899 901 913 923 943 949 961 979 989
1003 1007 1027 1037 1067 1073 1079 1081
1121 1139 1147 1157 1159 1189 1207 1219
1241 1247 1261 1271 1273 1333 1343 1349
1357 1363 1369
 
First > 9 is 10 at position 4.
First > 99 is 121 at position 11.
First > 999 is 1003 at position 74.
First > 9999 is 10201 at position 242.
First > 99999 is 100013 at position 2505.
First > 999999 is 1018081 at position 10538.</pre>
 
 
=={{header|Raku}}==
1 through 7 are fast. 8 and 9 take a bit longer.
1,462

edits