15 lines
531 B
Text
15 lines
531 B
Text
/* Predicate function that checks wether a positive integer is generalized k-Curzon number or not */
|
|
g_curzonp(n,k):=if mod((k^n)+1,k*n+1)=0 then true$
|
|
|
|
/* Function that returns a list of the first len generalized k-Curzon numbers */
|
|
g_curzon_count(len,k):=block(
|
|
[i:1,count:0,result:[]],
|
|
while count<len do (if g_curzonp(i,k) then (result:endcons(i,result),count:count+1),i:i+1),
|
|
result)$
|
|
|
|
/* Test cases */
|
|
g_curzon_count(50,2);
|
|
g_curzon_count(50,4);
|
|
g_curzon_count(50,6);
|
|
g_curzon_count(50,8);
|
|
g_curzon_count(50,10);
|