28 lines
674 B
Text
28 lines
674 B
Text
func Giuga(N0); \Return 'true' if Giuga number
|
|
int N0;
|
|
int N, F, Q1, Q2, L;
|
|
[N:= N0; F:= 2; L:= sqrt(N);
|
|
loop [Q1:= N/F;
|
|
if rem(0) = 0 then \found a prime factor
|
|
[Q2:= N0/F;
|
|
if rem((Q2-1)/F) # 0 then return false;
|
|
N:= Q1;
|
|
if F>N then quit;
|
|
]
|
|
else [F:= F+1;
|
|
if F>L then return false;
|
|
];
|
|
];
|
|
return true;
|
|
];
|
|
|
|
int N, C;
|
|
[N:= 3; C:= 0;
|
|
loop [if Giuga(N) then
|
|
[IntOut(0, N); ChOut(0, ^ );
|
|
C:= C+1;
|
|
if C >= 4 then quit;
|
|
];
|
|
N:= N+1;
|
|
];
|
|
]
|