Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
24
Task/Almost-prime/MiniScript/almost-prime.mini
Normal file
24
Task/Almost-prime/MiniScript/almost-prime.mini
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
primeFactory = function(n=2)
|
||||
if n < 2 then return ""
|
||||
for i in range(2, n)
|
||||
p = floor(n / i)
|
||||
q = n % i
|
||||
if not q then return str(i) + " " + str(primeFactory(p))
|
||||
end for
|
||||
return n
|
||||
end function
|
||||
|
||||
getAlmostPrimes = function(k)
|
||||
almost = []
|
||||
n = 2
|
||||
while almost.len < 10
|
||||
primes = primeFactory(n).trim.split
|
||||
if primes.len == k then almost.push(n)
|
||||
n += 1
|
||||
end while
|
||||
return almost
|
||||
end function
|
||||
|
||||
for i in range(1, 5)
|
||||
print i + ": " + getAlmostPrimes(i)
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue