Untouchable numbers: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: changed the code to be more idiomatic, optimized the sigmaP function (aliquot function) for about a 5% improvement in speed, updated (correct) count of untouchable numbers for up to and including a million.)
Line 209: Line 209:


=={{header|Julia}}==
=={{header|Julia}}==
I can prove that the number to required to sieve to assure only untouchables for N 100,000 is less than 2,499,000,000,
I can prove that the number to required to sieve to assure only untouchables for the interval 1:N is less than (N/2 - 1)^2,
but the 32,000,000 sieved below is just from doubling 1,000,000 and running the sieve until we get the Wren results.
but the 512,000,000 sieved below is just from doubling 1,000,000 and running the sieve until we get 150232 for the number
of untouchables under 1,000,000.
<lang julia>using Primes
<lang julia>using Primes


Line 222: Line 223:
end
end


const maxtarget, sievelimit = 100_000, 32_000_000
const maxtarget, sievelimit = 1_000_000, 512_000_000
const untouchables = ones(Bool, maxtarget)
const untouchables = ones(Bool, maxtarget)


Line 241: Line 242:
print(rpad(n, 5), i % 10 == 0 || i == 196 ? "\n" : "")
print(rpad(n, 5), i % 10 == 0 || i == 196 ? "\n" : "")
end
end
for N in [2000, 10, 100, 1000, 10_000, 100_000]
for N in [2000, 10, 100, 1000, 10_000, 100_000, 1_000_000]
println("The count of untouchable numbers ≤ $N is: ", count(x -> untouchables[x], 1:N))
println("The count of untouchable numbers ≤ $N is: ", count(x -> untouchables[x], 1:N))
end
end
Line 273: Line 274:
The count of untouchable numbers ≤ 10000 is: 1212
The count of untouchable numbers ≤ 10000 is: 1212
The count of untouchable numbers ≤ 100000 is: 13863
The count of untouchable numbers ≤ 100000 is: 13863
The count of untouchable numbers ≤ 1000000 is: 150232
</pre>
</pre>