Untouchable numbers: Difference between revisions
Content added Content deleted
Line 377: | Line 377: | ||
spds=:([:sum_of_proper_divisors"0(#\@i.-.i.&.:(p:inv))@*:)f. NB. remove primes which contribute 1 |
spds=:([:sum_of_proper_divisors"0(#\@i.-.i.&.:(p:inv))@*:)f. NB. remove primes which contribute 1 |
||
</lang> |
</lang> |
||
We may revisit to correct the larger untouchable tallies. |
We may revisit to correct the larger untouchable tallies. The straightforward algorithm presented is a little bit efficient, and, I claim, the verb <tt>(candidates-.spds)</tt> produces the full list of untouchable numbers up to its argument. It considers the sum of proper divisors through the argument squared, less primes. Since J is an algorithm description language, it may be "fairer" to state in J that "more resources required" than in some other language. [https://www.eecg.utoronto.ca/~jzhu/csc326/readings/iverson.pdf] |
||
Time (seconds) and space (bytes) on a high end six year old (new in 2015) laptop computer. |
|||
<pre> |
|||
timespacex'(-.candidates@#)/:~~.spds 10000' |
|||
600.285 4.29497e9 |
|||
</pre> |
|||
<pre> |
<pre> |
||
UNTOUCHABLES=:(candidates-.spds) 2000 NB. compute untouchable numbers |
UNTOUCHABLES=:(candidates-.spds) 2000 NB. compute untouchable numbers |
||
Line 400: | Line 406: | ||
1884 1888 1894 1896 1920 1922 1944 1956 1958 1960 1962 1972 1986 1992 |
1884 1888 1894 1896 1920 1922 1944 1956 1958 1960 1962 1972 1986 1992 |
||
SBD=:spds 10000 NB. sums of proper divisors of many integers |
|||
T=:/:~~.SBD NB. sort the nub |
|||
#T NB. leaving this many touchable numbers, which are dense through at least 10000 |
|||
47269787 |
|||
U=:(-.~candidates@#)T NB. possible untouchable numbers |
|||
head=: |
head=: 'n';'tally of possible untouchable numbers to n' |
||
head,:,.L:0;/|:(,.U&I.)10^#\i.5 NB. testing to ten thousand squared |
head,:,.L:0;/|:(,.U&I.)10^#\i.5 NB. testing to ten thousand squared |
||
┌──────┬──────────────────────────────────────────┐ |
┌──────┬──────────────────────────────────────────┐ |