Divisor enumeration Python memo

Divisor enumeration

The article below is just that. A note for yourself.

reference) https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56

def make_divisors(n):
    """
Function to enumerate divisors
    
Example) n = 100
    ⇒ 100 = 1 * 100, 2 * 50, 4 * 25, 5 * 20, 10 * 10
    ⇒ 1, 2, 4, 5,Look up to 10 and the pair(n // i)To list(n /i float)
    ⇒ 10 *Avoid duplication like 10&
    """
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: 
                divisors.append(n // i)

    divisors.sort()
    return divisors

Recommended Posts

Divisor enumeration Python memo
Python memo
python memo
python memo
Python memo
Python memo
Python memo
[Python] Memo dictionary
python beginner memo (9.2-10)
★ Memo ★ Python Iroha
[Python] EDA memo
Python 3 operator memo
[My memo] python
[Python] Basemap memo
Python beginner memo (2)
[Python] Numpy memo
My python environment memo
Python module (Python learning memo ④)
Visualization memo by Python
Python test package memo
[Python] Memo about functions
python regular expression memo
Binary search (python2.7) memo
[My memo] python -v / python -V
Python3 List / dictionary memo
[Memo] Python3 list sort
Python Tips (my memo)
[Python] Memo about errors
DynamoDB Script Memo (Python)
Python basic memo --Part 2
python recipe book Memo
Basic Python command memo
Python OpenCV tutorial memo
Python basic grammar memo
TensorFlow API memo (Python)
python useful memo links
Python decorator operation memo
Python basic memo --Part 1
Divisor enumeration when prime factorization is already known (Python)
Python memo (for myself): Array
Python exception handling (Python learning memo ⑥)
Python execution time measurement memo
Twitter graphing memo with Python
[Line / Python] Beacon implementation memo
Python and ruby slice memo
Python code memo for yourself
Raspberry Pi + Python + OpenGL memo
Python basic grammar (miscellaneous) Memo (3)
Python immutable type int memo
Python memo using perl --join
Python basic grammar (miscellaneous) Memo (2)
[MEMO] [Development environment construction] Python
[Python] virtualenv creation procedure memo
Python basic grammar (miscellaneous) Memo (4)
Regarding speeding up python (memo)
Python environment construction memo on Windows 10
Difference between java and python (memo)
[Python] Operation memo of pandas DataFrame
Python memo Anaconda x Jupyter Notebook
Python
Python QT app Standalone App conversion memo