## 2017年12月8日金曜日

### 数学 - Python - 代数学 - 整数 - 素数、素因数分解(正の約数の総数、すべての正の約数の和)

1. $\begin{array}{}58800\\ ={2}^{2}·14700\\ ={2}^{4}·3675\\ ={2}^{4}·5·735\\ ={2}^{4}·{5}^{2}·147\\ ={2}^{4}·{5}^{2}·7·21\\ ={2}^{4}·{5}^{2}·{7}^{2}·3\\ ={2}^{4}·3·{5}^{2}·{7}^{2}\end{array}$
$\begin{array}{}\tau \left(58800\right)\\ =\left(4+1\right)\left(1+1\right)\left(2+1\right)\left(2+1\right)\\ =5·2·3·3\\ =90\end{array}$
$\begin{array}{}\sigma \left(58800\right)\\ =\frac{{2}^{4+1}-1}{2-1}·\frac{{3}^{1+1}-1}{3-1}·\frac{{5}^{2+1}-1}{5-1}·\frac{{7}^{2+1}-1}{7-1}\\ =31·\frac{8}{2}·\frac{124}{4}·\frac{342}{6}\\ =31·124·57\\ =219108\end{array}$

コード(Emacs)

Python 3

#!/usr/bin/env python3
from sympy import pprint, factorint
import functools

n = 58800

ps = factorint(n)
pprint(factorint(n))

pprint(functools.reduce(lambda x, y: x * y, map(lambda v: v + 1, ps.values())))

pprint(functools.reduce(lambda x, y: x * y,
[(p ** (k + 1) - 1) / (p - 1) for p, k in ps.items()]))


$./sample6.py {2: 4, 3: 1, 5: 2, 7: 2} 90 219108.0$