Brilliant numbers: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: see talk page) |
Drkameleon (talk | contribs) (Added Arturo implementation) |
||
Line 29: | Line 29: | ||
=={{header|Arturo}}== |
|||
<lang rebol>brilliant?: function [x][ |
|||
pf: factors.prime x |
|||
and? -> 2 = size pf |
|||
-> equal? size digits first pf |
|||
size digits last pf |
|||
] |
|||
brilliants: new [] |
|||
i: 2 |
|||
while [100 > size brilliants][ |
|||
if brilliant? i -> 'brilliants ++ i |
|||
i: i + 1 |
|||
] |
|||
print "First 100 brilliant numbers:" |
|||
loop split.every: 10 brilliants 'row [ |
|||
print map to [:string] row 'item -> pad item 4 |
|||
] |
|||
print "" |
|||
i: 4 |
|||
nth: 0 |
|||
order: 1 |
|||
while [order =< 6] [ |
|||
if brilliant? i [ |
|||
nth: nth + 1 |
|||
if i >= 10^order [ |
|||
print ["First brilliant number >= 10 ^" order "is" i "at position" nth] |
|||
order: order + 1 |
|||
] |
|||
] |
|||
i: i + 1 |
|||
]</lang> |
|||
{{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 brilliant number >= 10 ^ 1 is 10 at position 4 |
|||
First brilliant number >= 10 ^ 2 is 121 at position 11 |
|||
First brilliant number >= 10 ^ 3 is 1003 at position 74 |
|||
First brilliant number >= 10 ^ 4 is 10201 at position 242 |
|||
First brilliant number >= 10 ^ 5 is 100013 at position 2505 |
|||
First brilliant number >= 10 ^ 6 is 1018081 at position 10538</pre> |
|||
=={{header|C++}}== |
=={{header|C++}}== |