user
Definitions
:   * *Untouchable numbers*   are also known as   *nonaliquot numbers*.

:   * An   untouchable number   is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer.   (From Wikipedia)

:   * The   *sum of all the proper divisors*   is also known as   the   *aliquot sum*.

:   * An   untouchable   are those numbers that are not in the image of the aliquot sum function.   (From Wikipedia)

:   * Untouchable numbers:   impossible values for the sum of all aliquot parts function.   (From OEIS:   The On-line Encyclopedia of Integer Sequences®)

:   * An untouchable number is a positive integer that is not the sum of the proper divisors of any number.   (From MathWorld™)

Observations and conjectures

All untouchable numbers   >  **5**  are composite numbers.

No untouchable number is perfect.

No untouchable number is sociable.

No untouchable number is a Mersenne prime.

No untouchable number is   one more   than a prime number,   since if   **p**   is prime,   then
the sum of the proper divisors of   **p2**   is  **p + 1**.

No untouchable number is   three more   than an odd prime number,   since if   **p**   is an odd prime,   then the
sum of the proper divisors of   **2p**   is  **p + 3**.

The number  **5**  is believed to be the only odd untouchable number,   but this has not been proven:   it would follow from a
slightly stronger version of the   Goldbach's conjecture,   since the sum of the
proper divisors of   **pq**   (with   **p**, **q**   being
distinct primes)   is   **1 + p + q**.

There are infinitely many untouchable numbers,   a fact that was proven
by   Paul Erdős.

According to Chen & Zhao,   their natural density is at least   **d > 0.06**.

Task
:   * show  (in a grid format)  all untouchable numbers  ≤  2,000.
    * show (for the above)   the   *count*   of untouchable numbers.
    * show the   *count*   of untouchable numbers from unity up to   (inclusive):

    :   :   :   * 10
                * 100
                * 1,000
                * 10,000
                * 100,000
                * ... or as high as is you think is practical.

    * all output is to be shown here, on this page.

See also
:   * Wolfram MathWorld:   untouchable number.
    * OEIS:   A005114 untouchable numbers.
    * OEIS:   a list of all untouchable numbers below 100,000   (inclusive).
    * Wikipedia: untouchable number.
    * Wikipedia: Goldbach's conjecture.
assistant
Borrow the proper divisors routine from here.

**Translation of**: Wren

```
# 20210220 Raku programming solution

sub propdiv (\x) {
   my @l = 1 if x > 1;
   (2 .. x.sqrt.floor).map: -> \d {
      unless x % d { @l.push: d; my \y = x div d; @l.push: y if y != d }
   }
   @l
}

sub sieve (\n) {
   my %s;
   for (0..(n+1)) -> \k {
      given ( [+] propdiv k ) { %s{$_} = True if $_ ≤ (n+1) }
   }
   %s;
}

my \limit = 1e5;
my %c = ( grep { !.is-prime }, 1..limit ).Set; # store composites
my %s = sieve(14 * limit);
my @untouchable = 2, 5;

loop ( my \n = $ = 6 ; n ≤ limit ; n += 2 ) {
   @untouchable.append(n) if (!%s{n} && %c{n-1} && %c{n-3})
}

my ($c, $last) = 0, False;  
for @untouchable.rotor(10) { 
   say [~] @_».&{$c++ ; $_ > 2000 ?? ( $last = True and last ) !! .fmt: "%6d "}
   $c-- and last if $last
}

say "\nList of untouchable numbers ≤ 2,000 : $c \n"; 

my ($p, $count) = 10,0;
BREAK: for @untouchable -> \n {
   $count++;
   if (n > $p) {
      printf "%6d untouchable numbers were found  ≤ %7d\n", $count-1, $p;
      last BREAK if limit == ($p *= 10)
   }
}
printf "%6d untouchable numbers were found  ≤ %7d\n", +@untouchable, limit

```

Output:

```
     2      5     52     88     96    120    124    146    162    188
   206    210    216    238    246    248    262    268    276    288
   290    292    304    306    322    324    326    336    342    372
   406    408    426    430    448    472    474    498    516    518
   520    530    540    552    556    562    576    584    612    624
   626    628    658    668    670    708    714    718    726    732
   738    748    750    756    766    768    782    784    792    802
   804    818    836    848    852    872    892    894    896    898
   902    926    934    936    964    966    976    982    996   1002
  1028   1044   1046   1060   1068   1074   1078   1080   1102   1116
  1128   1134   1146   1148   1150   1160   1162   1168   1180   1186
  1192   1200   1212   1222   1236   1246   1248   1254   1256   1258
  1266   1272   1288   1296   1312   1314   1316   1318   1326   1332
  1342   1346   1348   1360   1380   1388   1398   1404   1406   1418
  1420   1422   1438   1476   1506   1508   1510   1522   1528   1538
  1542   1566   1578   1588   1596   1632   1642   1650   1680   1682
  1692   1716   1718   1728   1732   1746   1758   1766   1774   1776
  1806   1816   1820   1822   1830   1838   1840   1842   1844   1852
  1860   1866   1884   1888   1894   1896   1920   1922   1944   1956
  1958   1960   1962   1972   1986   1992

List of untouchable numbers ≤ 2,000 : 196

     2 untouchable numbers were found  ≤      10
     5 untouchable numbers were found  ≤     100
    89 untouchable numbers were found  ≤    1000
  1212 untouchable numbers were found  ≤   10000
 13863 untouchable numbers were found  ≤  100000

```