Jump to content

Untouchable numbers: Difference between revisions

m
(→‎{{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:
 
=={{header|Julia}}==
I can prove that the number to required to sieve to assure only untouchables for Nthe 100,000interval 1:N is less than (N/2,499,000,000, - 1)^2,
but the 32512,000,000 sieved below is just from doubling 1,000,000 and running the sieve until we get the150232 Wrenfor the results.number
of untouchables under 1,000,000.
<lang julia>using Primes
 
Line 222 ⟶ 223:
end
 
const maxtarget, sievelimit = 100_0001_000_000, 32_000_000512_000_000
const untouchables = ones(Bool, maxtarget)
 
Line 241 ⟶ 242:
print(rpad(n, 5), i % 10 == 0 || i == 196 ? "\n" : "")
end
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))
end
Line 273 ⟶ 274:
The count of untouchable numbers ≤ 10000 is: 1212
The count of untouchable numbers ≤ 100000 is: 13863
The count of untouchable numbers ≤ 1000000 is: 150232
</pre>
 
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.