Deceptive numbers: Difference between revisions
Content added Content deleted
m (→without bigints: added js output) |
|||
Line 64: | Line 64: | ||
<pre> |
<pre> |
||
91 259 451 481 703 1729 2821 2981 3367 4141 4187 5461 6533 6541 6601 |
91 259 451 481 703 1729 2821 2981 3367 4141 4187 5461 6533 6541 6601 |
||
</pre> |
|||
=={{header|Amazing Hopper}}== |
|||
{{Translation|C}} |
|||
<syntaxhighlight lang="c"> |
|||
#include <jambo.h> |
|||
#prototype isdeceptive(_X_) |
|||
#prototype modulepow(_X_,_Y_,_Z_) |
|||
#synon _isdeceptive Isdeceptive |
|||
#synon _modulepow ModulePow |
|||
Main |
|||
i = 49, c=0 |
|||
Iterator ( ++i, #(c <> 50), \ |
|||
Print only if ( Is deceptive 'i', Set 'i,"\n"'; ++c ) ) |
|||
End |
|||
Subrutines |
|||
is deceptive ( n ) |
|||
ret=0, x=7 |
|||
When ( And( Bitand(n,1), And( Mod(n,3), Mod(n,5) )) ) { |
|||
Iterator( x+=6, #( (x*x) <= n ),\ |
|||
#(!( (n%x) && (n%(x+4)) )), do{ \ |
|||
Let ' ret := Equals( Module Pow (10, Minus one(n), n), 1) ' } ) |
|||
} |
|||
Return ' ret ' |
|||
module pow(b, e, m) |
|||
Loop for (p = 1, e, e >>= 1) |
|||
Bitand(e, 1), do{ #( p = (p * b) % m ) } |
|||
#( b = (b * b) % m ) |
|||
Next |
|||
Return (p) |
|||
</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 |
|||
46657 |
|||
48433 |
|||
50851 |
|||
50881 |
|||
52633 |
|||
54913 |
|||
57181 |
|||
63139 |
|||
63973 |
|||
</pre> |
</pre> |
||