Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
30
Task/Deceptive-numbers/AWK/deceptive-numbers.awk
Normal file
30
Task/Deceptive-numbers/AWK/deceptive-numbers.awk
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
function modpow(b, e, m, r) {
|
||||
for (r = 1; e > 0; e = int(e / 2)) {
|
||||
if (e % 2 == 1)
|
||||
r = r * b % m
|
||||
b = b * b % m
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
function is_pseudo(n, i, p, r) {
|
||||
if (modpow(10, n - 1, n) == 1) {
|
||||
r = int(sqrt(n))
|
||||
while ((p = primes[++i]) <= r)
|
||||
if (n % p == 0)
|
||||
return 1
|
||||
primes[++l] = n
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
primes[l = 1] = n = 7
|
||||
split("4 2 4 2 4 6 2 6", wheel)
|
||||
|
||||
do if (is_pseudo(n += wheel[i = i % 8 + 1])) {
|
||||
printf " %u", n
|
||||
++c
|
||||
} while (c != 50)
|
||||
print
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
R=: (10x #. #&1)"0
|
||||
deceptive=: 1&p: < 0 = ] | R@<:
|
||||
|
||||
2+I.deceptive 2+i.10000
|
||||
91 259 451 481 703 1729 2821 2981 3367 4141 4187 5461 6533 6541 6601 7471 7777 8149 8401 8911 10001
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
deceptives=: {{
|
||||
r=.$k=.10x #.}.1#~j=.9
|
||||
while. y>#r do.
|
||||
if. 0<2|j do.
|
||||
if. 0<5|j do.
|
||||
if. 0=1 p:j do.
|
||||
if. 0=0]j|k do.
|
||||
r=. r, j
|
||||
end.
|
||||
end.
|
||||
end.
|
||||
end.
|
||||
k=. 1 10x p.k
|
||||
j=. j+1
|
||||
end.
|
||||
r
|
||||
}}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
deceptives 21
|
||||
91 259 451 481 703 1729 2821 2981 3367 4141 4187 5461 6533 6541 6601 7471 7777 8149 8401 8911 10001
|
||||
4
Task/Deceptive-numbers/J/deceptive-numbers.j
Normal file
4
Task/Deceptive-numbers/J/deceptive-numbers.j
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
wheel=. 4 6 2 6 4 2 4 2
|
||||
fermat=. {{1 = 10 (y&|@^) <: y}}"0
|
||||
|
||||
_10 ]\ (#~ fermat) (#~ 0&p:) +/\ 49 , 15e4 $ wheel
|
||||
|
|
@ -1,22 +1,15 @@
|
|||
import math.big
|
||||
|
||||
fn is_prime(n int) bool {
|
||||
if n < 2 {
|
||||
return false
|
||||
} else if n%2 == 0 {
|
||||
return n == 2
|
||||
} else if n%3 == 0 {
|
||||
return n == 3
|
||||
} else {
|
||||
if n < 2 {return false}
|
||||
else if n % 2 == 0 {return n == 2}
|
||||
else if n % 3 == 0 {return n == 3}
|
||||
else {
|
||||
mut d := 5
|
||||
for d*d <= n {
|
||||
if n%d == 0 {
|
||||
return false
|
||||
}
|
||||
for d * d <= n {
|
||||
if n % d == 0 {return false}
|
||||
d += 2
|
||||
if n%d == 0 {
|
||||
return false
|
||||
}
|
||||
if n % d == 0 {return false}
|
||||
d += 4
|
||||
}
|
||||
return true
|
||||
|
|
@ -34,7 +27,7 @@ fn main() {
|
|||
hundred := big.integer_from_int(100)
|
||||
mut deceptive := []i64{}
|
||||
for count < limit {
|
||||
if !is_prime(int(n)) && n%3 != 0 && n%5 != 0 {
|
||||
if !is_prime(int(n)) && n % 3 != 0 && n % 5 != 0 {
|
||||
bn := big.integer_from_i64(n)
|
||||
t = repunit % bn
|
||||
if t == zero {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* deceptive_numbers.wren */
|
||||
/* Deceptive_numbers.wren */
|
||||
|
||||
import "./gmp" for Mpz
|
||||
import "./math" for Int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue