Post History
BQN, 21 bytesSBCS (¬·×-+´·/0=↕⊸|)¨⊸⊔1+↕ Run online! Mostly one big train used to find the appropriate group for each number, to be used with Group (⊔). The combining functions in a train norma...
Answer
#1: Initial revision
# [BQN](https://mlochbaum.github.io/BQN/), 21 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup> ``` (¬·×-+´·/0=↕⊸|)¨⊸⊔1+↕ ``` [Run online!](https://mlochbaum.github.io/BQN/try.html#code=RuKGkCjCrMK3w5ctK8K0wrcvMD3ihpXiirh8KcKo4oq44oqUMSvihpUKCj5GwqggNDnigL8zMuKAvzE24oC/MjnigL8yMw==) Mostly one big [train](https://mlochbaum.github.io/BQN/doc/train.html) used to find the appropriate group for each number, to be used with [Group](https://mlochbaum.github.io/BQN/doc/group.html) (`⊔`). The combining functions in a train normally have two arguments, but Nothing (`·`) can be used on the left to not pass a left argument. See also [Indices](https://mlochbaum.github.io/BQN/doc/replicate.html#indices) (`/`), and note that Modulus (`|`) is backwards relative to C-like `%`. ``` (¬·×-+´·/0=↕⊸|)¨⊸⊔1+↕ 1+↕ # One plus range: 1…𝕩 ( )¨ # On each of these (n): ↕ # Range 0…n-1 ⊸| # Remainder dividing into n 0= # Equals zero ·/ # Indices where true: proper divisors -+´ # Sum with initial value -n ·× # Sign ¬ # One minus that ⊸⊔ # Use to group 1+↕ ``` There might be a better solution based on taking the modulus on all pairs instead of one at a time. `(¬·×-+˝(⊣×≠>|)⌜˜)⊸⊔1+↕` is close at 22 bytes.