Data Update
This commit is contained in:
parent
e50b5c3114
commit
633b36288a
206 changed files with 4762 additions and 965 deletions
33
Task/Anti-primes/MiniScript/anti-primes.mini
Normal file
33
Task/Anti-primes/MiniScript/anti-primes.mini
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Find the first 20 antiprimes.
|
||||
|
||||
// returns a table of the first goal antiprimes
|
||||
antiprimes = function(goal)
|
||||
maxNumber = 0
|
||||
ndc = [] // table of divisor counts - initially empty
|
||||
list = [0] * goal; number = 1; mostFactors = 0
|
||||
aCount = 0
|
||||
while aCount < goal
|
||||
if number > maxNumber then
|
||||
// need a bigger table of divisor counts
|
||||
maxNumber = maxNumber + 5000
|
||||
ndc = [1] * ( maxNumber + 1 )
|
||||
ndc[ 0 ] = 0
|
||||
for i in range( 2, maxNumber )
|
||||
for j in range( i, maxNumber, i )
|
||||
ndc[ j ] = ndc[ j ] + 1
|
||||
end for
|
||||
end for
|
||||
end if
|
||||
factors = ndc[ number ]
|
||||
if factors > mostFactors then
|
||||
list[ aCount ] = number
|
||||
mostFactors = factors
|
||||
aCount = aCount + 1
|
||||
end if
|
||||
number = number + 1
|
||||
end while
|
||||
return list
|
||||
end function
|
||||
|
||||
// display the antiprimes
|
||||
print antiprimes( 20 ).join( " " )
|
||||
Loading…
Add table
Add a link
Reference in a new issue