Curzon numbers: Difference between revisions

m
(Added Easylang)
 
(3 intermediate revisions by 2 users not shown)
Line 436:
=={{header|EasyLang}}==
{{trans|FreeBASIC}}
<syntaxhighlight lang=easylang>
func pow_mod b power modulus .
x = 1
Line 448:
return x
.
numfmt 0 4
for k = 2 step 2 to 10
numfmt 0 0
print "The firstFirst 50 Curzon numbers using a base of " & k & ":"
numfmt 0 4
n = 1
count = 0
Line 460 ⟶ 461:
if count <= 50
write " " & n
if count mod 109 = 0
print ""
.
Line 1,567 ⟶ 1,568:
 
46845</pre>
 
=={{header|PARI/GP}}==
{{trans|Mathematica/Wolfram_Language}}
<syntaxhighlight lang="PARI/GP">
/* Define the CurzonNumberQ function for base b */
powermod(a,k,n)=lift(Mod(a,n)^k)
CurzonNumberQ(b, n) = (powermod(b,n,b*n+1)== b*n);
 
/* Define a function to find Curzon numbers within a range for base b */
FindCurzonNumbers(b, maxrange) = {
local(val, res, i);
val = vector(maxrange);
res = [];
for(i = 1, maxrange,
if(CurzonNumberQ(b, i), res = concat(res, i));
);
return(Vec(res));
}
 
/* Select and display the first 50 Curzon numbers and the 1000th for base 2 */
val = FindCurzonNumbers(2, 100000);
print(vector(50, i, val[i])); /* First 50 */
print(val[1000]); /* 1000th Curzon number */
 
/* Select and display for base 4 */
val = FindCurzonNumbers(4, 100000);
print(vector(50, i, val[i])); /* First 50 */
print(val[1000]); /* 1000th Curzon number */
 
/* Select and display for base 6 */
val = FindCurzonNumbers(6, 100000);
print(vector(50, i, val[i])); /* First 50 */
print(val[1000]); /* 1000th Curzon number */
 
/* Select and display for base 8 */
val = FindCurzonNumbers(8, 100000);
print(vector(50, i, val[i])); /* First 50 */
print(val[1000]); /* 1000th Curzon number */
 
/* Select and display for base 10 */
val = FindCurzonNumbers(10, 100000);
print(vector(50, i, val[i])); /* First 50 */
print(val[1000]); /* 1000th Curzon number */
</syntaxhighlight>
{{out}}
<pre>
[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]
8646
[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]
9375
[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]
20717
[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]
22176
[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]
46845
</pre>
 
=={{header|Perl}}==
Line 2,149 ⟶ 2,207:
{{libheader|Wren-gmp}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">/* curzon_numbersCurzon_numbers.wren */
 
import "./gmp" for Mpz
Line 2,232 ⟶ 2,290:
{{libheader|Wren-math}}
Alternatively, using ''Int.modPow'' rather than ''GMP'' so it will run on Wren-cli, albeit about 6 times more slowly.
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int
import "./fmt" for Fmt
 
1,981

edits