{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import itertools, sympy\n", "\n", "def aliquot_sum(n):\n", " return sympy.divisor_sigma(n) - n\n", "\n", "abundants = {n for n in range(2, 28123 + 1) if aliquot_sum(n) > n}\n", "sum_of_abundants = set(a + b for (a, b) in itertools.combinations_with_replacement(abundants, 2))\n", "sum(set(range(1, 28123+1)) - sum_of_abundants)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" }, "title": "Non-abundant sums" }, "nbformat": 4, "nbformat_minor": 2 }