Deceptive numbers: Difference between revisions

Added XPL0 example.
(Added the missing code!!!!)
(Added XPL0 example.)
Line 1,009:
[91, 259, 451, 481, 703, 1729, 2821, 2981, 3367, 4141, 4187, 5461, 6533, 6541, 6601, 7471, 7777, 8149, 8401, 8911, 10001, 11111, 12403, 13981, 14701]
</pre>
 
=={{header|XPL0}}==
{{trans|C}}
<syntaxhighlight lang "XPL0">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;
];
]</syntaxhighlight>
{{out}}
<pre>
91 259 451 481 703 1729 2821 2981 3367 4141
4187 5461 6533 6541 6601 7471 7777 8149 8401 8911
10001 11111 12403 13981 14701 14911 15211 15841 19201 21931
22321 24013 24661 27613 29341 34133 34441 35113 38503 41041
45527</pre>
295

edits