Deceptive numbers: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
 
(5 intermediate revisions by 3 users not shown)
Line 439:
137149 138481 139231 145181 147001 148417 152551 158497 162401 164761
166499 170017 172081 179881 188191 188269 188461 188501 196651 201917
</pre>
 
=={{header|EasyLang}}==
{{trans|C}}
<syntaxhighlight>
func modpow b e m .
r = 1
while e > 0
if e mod 2 = 1
r = r * b mod m
.
b = b * b mod m
e = e div 2
.
return r
.
func is_deceptive n .
if n mod 2 = 1 and n mod 3 <> 0 and n mod 5 <> 0
if modpow 10 (n - 1) n = 1
x = 7
while x * x <= n
if n mod x = 0 or n mod (x + 4) = 0
return 1
.
x += 6
.
.
.
.
while cnt < 10
n += 1
if is_deceptive n = 1
write n & " "
cnt += 1
.
.
</syntaxhighlight>
{{out}}
<pre>
91 259 451 481 703 1729 2821 2981 3367 4141
</pre>
 
Line 485 ⟶ 525:
if Isprime(n)>1 and Divides(n,Rep(n-1)) then !!n; c:+; fi
od;</syntaxhighlight>
 
=={{header|FreeBASIC}}==
{{trans|XPLo}}
<syntaxhighlight lang="vbnet">Function ModPow(b As Uinteger, e As Uinteger, m As Uinteger) As Uinteger
Dim As Uinteger p = 1
While e <> 0
If (e And 1) Then p = (p*b) Mod m
b = (b*b) Mod m
e Shr= 1
Wend
Return p
End Function
 
Function isDeceptive(n As Uinteger) As Uinteger
Dim As Uinteger x
If (n And 1) <> 0 Andalso (n Mod 3) <> 0 Andalso (n Mod 5) <> 0 Then
x = 7
While x*x <= n
If (n Mod x) = 0 Orelse (n Mod (x+4)) = 0 Then Return (ModPow(10, n-1, n) = 1)
x += 6
Wend
End If
Return 0
End Function
 
Dim As Uinteger c = 0, i = 49
While c <> 41 ' limit for signed 32-bit integers
If isDeceptive(i) Then
Print Using "#######"; Csng(i);
c += 1
If (c Mod 10) = 0 Then Print
End If
i += 1
Wend
 
Sleep</syntaxhighlight>
{{out}}
<pre>Same as XPLo entry.</pre>
 
=={{header|Go}}==
Line 683 ⟶ 761:
=={{header|langur}}==
{{trans|ALGOL 68}}
<syntaxhighlight lang="langur">val .isPrime = f fn(.i == 2 or .i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2{
{{works with|langur|0.8.1}}
.i == 2 or .i > 2 and
<syntaxhighlight lang="langur">val .isPrime = f .i == 2 or .i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2
not any fn(.x) { .i div .x }, pseries 2 .. .i ^/ 2
}
 
var .nums = []
Line 690 ⟶ 770:
 
for .n = 9; len(.nums) < 10; .n += 2 {
.repunit = .repunit x* 100 + 11
if not .isPrime(.n) and .repunit div .n {
.nums = more .nums, .n
885

edits