Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
31
Task/Deceptive-numbers/EasyLang/deceptive-numbers.easy
Normal file
31
Task/Deceptive-numbers/EasyLang/deceptive-numbers.easy
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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
|
||||
.
|
||||
.
|
||||
33
Task/Deceptive-numbers/FreeBASIC/deceptive-numbers.basic
Normal file
33
Task/Deceptive-numbers/FreeBASIC/deceptive-numbers.basic
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
val .isPrime = f .i == 2 or .i > 2 and not any f(.x) .i div .x, pseries 2 .. .i ^/ 2
|
||||
val .isPrime = f .i == 2 or .i > 2 and
|
||||
not any f(.x) .i div .x, pseries 2 .. .i ^/ 2
|
||||
|
||||
var .nums = []
|
||||
var .repunit = 111_111
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue