Erdős–Woods numbers: Difference between revisions

→‎{{header|Wren}}: Tidied but no quicker.
(julia example)
(→‎{{header|Wren}}: Tidied but no quicker.)
Line 201:
var A = BigInt.new(a)
var s = primes.map { |p| Conv.btoi(A % p == 0).toString }.join()[-1..0]
divs.add(BigInt.new(Conv.atoi(s, 2)))
}
}
var partitions = [ [zero, zero, two.pow(np) - one] ]
var key = Fn.new { |x| Conv.bin(divs[x] | divs[n-x]).toBaseString(2)[-1..0].indexOf("1") }
var cmp = Fn.new { |i, j| (key.call(j) - key.call(i)).sign }
for (i in Sort.merge((1...n).toList, cmp)) {
var newPartitions = []
var factors = BigInt.new(divs[i])
var otherFactors = BigInt.new(divs[n-i])
for (p in partitions) {
var setA = p[0]
Line 251:
}
var N = BigInt.new(n)
var temp = x.modPowmodInv(-1, y) * N % y * x - N
result = result ? BigInt.min(result, temp) : temp
}
Line 259:
var k = 3
var count = 0
System.print("THeThe first 20 Erdős–Woods numbers and their minimum interval start values are:")
while (count < 20) {
var a = ew.call(k)
Line 271:
{{out}}
<pre>
THeThe first 20 Erdős–Woods numbers and their minimum interval start values are:
16 -> 2184
22 -> 3521210
9,483

edits