Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Deceptive-numbers/XPL0/deceptive-numbers.xpl0
Normal file
37
Task/Deceptive-numbers/XPL0/deceptive-numbers.xpl0
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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;
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue