Revision b6fa3cc9-3b7e-4dc4-b07d-2225b7c7b616 - Code Golf Stack Exchange

# [Python 2], <s>41</s> 40 bytes

<!-- language-all: lang-python -->

 n=k=j=input()
 while~k<0:j-=1;k-=j>>n%j*n

Output is [via exit code], so **0** is truthy and **1** is falsy.

[Try it online!]

### How it works

After setting all of **n**, **k**, and **j** to the input from STDIN, we enter the *while* loop. Said loop will break as soon as **-k - 1 = ~k ≥ 0**, i.e., once **k ≤ -1** / **k < 0**.

In each iteration, we first decrement **j** to consider only proper divisors of **n**. If **j** is a divisor of **n**, `n%j` yields **0** and **j >> n%j*n = j/2<sup>0</sup> = j** gets subtracted from **k**. However, if **j** does *not* divide **n**, `n%j` is positive, so `n%j*n` is at least **n > log<sub>2</sub> j** and **j >> n%j*n = j / 2<sup>n%j*n</sup> = 0** is subtracted from **k**.

For abundant numbers, **k** will reach a negative value before or when **j** becomes **1**, since the sum of **n**'s proper divisors is strictly greater than **n**. In this case, we break out of the *while* loop and the program finishes normally.

However, if **n** is *not* abundant, **j** eventually reaches **0**. In this case, `n%j` throws a *ZeroDivisionError* and the program exits with an error.

[Python 2]: https://docs.python.org/2/
[via exit code]: http://meta.codegolf.stackexchange.com/a/5330/12012
[Try it online!]: https://tio.run/nexus/python2#PY1BDsIgFETXcIq/MbSNTcoWpXdB@lWg/hLAqBuvjujC3WTm5Y3dFgQNQohKOmivHcV76Xr@uLoV3@E4KT9qeQij9vNMOz9QbTDn5y1BwVysyQiOIBm6YCf3cpK94uynaeLV3E6LUX@Us5JebWf4RAu2vbcck6MCxFtpMZbvHE3O9QM "Python 2 – TIO Nexus"

AltStyle によって変換されたページ (->オリジナル) /