Curzon numbers: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
(Added Algol 68) |
||
Line 80: | Line 80: | ||
Thousandth Curzon with k = 10: 46845. |
Thousandth Curzon with k = 10: 46845. |
||
</pre> |
|||
=={{header|ALGOL 68}}== |
|||
{{Trans|C++}} |
|||
<syntaxhighlight lang="algol68"> |
|||
BEGIN # find some generalised Curzon numbers - translation of the C++ sample # |
|||
PROC modpow = ( LONG INT rqd base, rqd exp, mod )LONG INT: |
|||
IF mod = 1 |
|||
THEN 0 |
|||
ELSE |
|||
LONG INT result := 1; |
|||
LONG INT base := rqd base MOD mod; |
|||
LONG INT exp := rqd exp; |
|||
WHILE exp > 0 DO |
|||
IF ODD exp THEN |
|||
result TIMESAB base MODAB mod |
|||
FI; |
|||
base TIMESAB base MODAB mod; |
|||
exp OVERAB 2 |
|||
OD; |
|||
result |
|||
FI # modpow # ; |
|||
PROC is curzon = ( LONG INT n, k )BOOL: |
|||
BEGIN |
|||
LONG INT m = k * n + 1; |
|||
modpow( k, n, m ) + 1 = m |
|||
END # is curon # ; |
|||
BEGIN # taks # |
|||
LONG INT k := 0; |
|||
WHILE k +:= 2; |
|||
k <= 10 |
|||
DO |
|||
print( ( "Curzon numbers with base ", whole( k, 0 ), ":", newline ) ); |
|||
LONG INT count := 0, n := 0; |
|||
WHILE n +:= 1; |
|||
count < 50 |
|||
DO |
|||
IF is curzon( n, k ) THEN |
|||
print( ( whole( n, -4 ) |
|||
, IF ( count +:= 1 ) MOD 10 = 0 THEN newline ELSE " " FI |
|||
) |
|||
) |
|||
FI |
|||
OD; |
|||
WHILE IF is curzon( n, k ) THEN count +:= 1 FI; |
|||
count < 1000 |
|||
DO |
|||
n +:= 1 |
|||
OD; |
|||
print( ( "1000th Curzon number with base ", whole( k, 0 ), ": ", whole( n, 0 ) ) ); |
|||
print( ( newline, newline ) ) |
|||
OD |
|||
END # task # |
|||
END |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Curzon numbers with base 2: |
|||
1 2 5 6 9 14 18 21 26 29 |
|||
30 33 41 50 53 54 65 69 74 78 |
|||
81 86 89 90 98 105 113 114 125 134 |
|||
138 141 146 153 158 165 173 174 186 189 |
|||
194 198 209 210 221 230 233 245 249 254 |
|||
1000th Curzon number with base 2: 8646 |
|||
Curzon numbers with base 4: |
|||
1 3 7 9 13 15 25 27 37 39 |
|||
43 45 49 57 67 69 73 79 87 93 |
|||
97 99 105 115 127 135 139 153 163 165 |
|||
169 175 177 183 189 193 199 205 207 213 |
|||
219 235 249 253 255 265 267 273 277 279 |
|||
1000th Curzon number with base 4: 9375 |
|||
Curzon numbers with base 6: |
|||
1 6 30 58 70 73 90 101 105 121 |
|||
125 146 153 166 170 181 182 185 210 233 |
|||
241 242 266 282 290 322 373 381 385 390 |
|||
397 441 445 446 450 453 530 557 562 585 |
|||
593 601 602 605 606 621 646 653 670 685 |
|||
1000th Curzon number with base 6: 20717 |
|||
Curzon numbers with base 8: |
|||
1 14 35 44 72 74 77 129 131 137 |
|||
144 149 150 185 200 219 236 266 284 285 |
|||
299 309 336 357 381 386 390 392 402 414 |
|||
420 441 455 459 470 479 500 519 527 536 |
|||
557 582 600 602 617 639 654 674 696 735 |
|||
1000th Curzon number with base 8: 22176 |
|||
Curzon numbers with base 10: |
|||
1 9 10 25 106 145 190 193 238 253 |
|||
306 318 349 385 402 462 486 526 610 649 |
|||
658 678 733 762 810 990 994 1033 1077 1125 |
|||
1126 1141 1149 1230 1405 1422 1441 1485 1509 1510 |
|||
1513 1606 1614 1630 1665 1681 1690 1702 1785 1837 |
|||
1000th Curzon number with base 10: 46845 |
|||
</pre> |
</pre> |
||