37 lines
666 B
Text
37 lines
666 B
Text
func ModPow(B, E, M);
|
|
int B, E, M, P;
|
|
[P:= 1;
|
|
while E # 0 do
|
|
[if E & 1 then
|
|
P:= rem(P*B/M);
|
|
B:= rem(B*B/M);
|
|
E:= E >> 1;
|
|
];
|
|
return P;
|
|
];
|
|
|
|
func IsDeceptive(N);
|
|
int N, X;
|
|
[if (N&1) # 0 and rem(N/3) # 0 and rem(N/5) # 0 then
|
|
[X:= 7;
|
|
while X*X <= N do
|
|
[if rem(N/X) = 0 or rem(N/(X+4)) = 0 then
|
|
return ModPow(10, N-1, N) = 1;
|
|
X:= X + 6;
|
|
];
|
|
];
|
|
return false;
|
|
];
|
|
|
|
int C, I;
|
|
[Format(7, 0);
|
|
I:= 49; C:= 0;
|
|
while C # 41 do \limit for signed 32-bit integers
|
|
[if IsDeceptive(I) then
|
|
[RlOut(0, float(I));
|
|
C:= C+1;
|
|
if rem(C/10) = 0 then CrLf(0);
|
|
];
|
|
I:= I+1;
|
|
];
|
|
]
|