Data update
This commit is contained in:
parent
796d366b97
commit
35bcdeebf8
504 changed files with 7045 additions and 610 deletions
27
Task/Anti-primes/EasyLang/anti-primes.easy
Normal file
27
Task/Anti-primes/EasyLang/anti-primes.easy
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
func divcnt v .
|
||||
n = v
|
||||
tot = 1
|
||||
p = 2
|
||||
while p <= sqrt n
|
||||
cnt = 1
|
||||
while n mod p = 0
|
||||
cnt += 1
|
||||
n = n div p
|
||||
.
|
||||
p += 1
|
||||
tot *= cnt
|
||||
.
|
||||
if n > 1
|
||||
tot *= 2
|
||||
.
|
||||
return tot
|
||||
.
|
||||
while count < 20
|
||||
n += 1
|
||||
divs = divcnt n
|
||||
if divs > max
|
||||
print n
|
||||
max = divs
|
||||
count += 1
|
||||
.
|
||||
.
|
||||
31
Task/Anti-primes/Grain/anti-primes.grain
Normal file
31
Task/Anti-primes/Grain/anti-primes.grain
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import File from "sys/file"
|
||||
let mut maxDiv = 0
|
||||
let mut count = 0
|
||||
let numaprimes = 20
|
||||
let countDivisors = n => {
|
||||
if (n < 1) {
|
||||
1
|
||||
} else {
|
||||
let mut count = 2
|
||||
let mut target = n / 2
|
||||
for (let mut i = 1; i <= target; i += 1) {
|
||||
if (n % i == 0) {
|
||||
count += 1
|
||||
} else {
|
||||
void
|
||||
}
|
||||
}
|
||||
count
|
||||
}
|
||||
}
|
||||
print("\nThe first 20 anti-primes are: ")
|
||||
let mut d = 0
|
||||
for (let mut j = 1; count < numaprimes; j += 1) {
|
||||
d = countDivisors(j)
|
||||
if (d > maxDiv) {
|
||||
File.fdWrite(File.stdout, Pervasives.toString(j))
|
||||
File.fdWrite(File.stdout, " ")
|
||||
maxDiv = d
|
||||
count += 1
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue