Skip to content

Instantly share code, notes, and snippets.

@iepathos
Last active December 17, 2015 12:19

Revisions

  1. iepathos revised this gist May 20, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions python_factorization.py
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    from math import sqrt

    """
    Fast factorization algorithm. Uses tuples instead of lists
    and sqrt over exponentiation.
    Fast factorization algorithm. Uses tuples instead of lists
    and sqrt over exponentiation.
    """
    def factors(n):
    return set(x for tup in ([i, n//i]
  2. iepathos revised this gist May 20, 2013. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions python_factorization.py
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,7 @@
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    from math import sqrt

    ### FIND FACTORS
    """
    Fastest factorization algorithm. Uses tuples instead of lists
    Fast factorization algorithm. Uses tuples instead of lists
    and sqrt over exponentiation.
    """
    def factors(n):
  3. iepathos revised this gist May 20, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion python_factorization.py
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    ### FIND FACTORS
    """
    Fastest factorization algorithm. Uses tuples instead of lists
    and sqrt imported to the namespace over exponentiation.
    and sqrt over exponentiation.
    """
    def factors(n):
    return set(x for tup in ([i, n//i]
  4. iepathos renamed this gist May 20, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. iepathos revised this gist May 19, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion iepathos_factors.py
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@

    ### FIND FACTORS
    """
    Fastest factorization algorithm? Uses tuples instead of lists
    Fastest factorization algorithm. Uses tuples instead of lists
    and sqrt imported to the namespace over exponentiation.
    """
    def factors(n):
  6. iepathos created this gist May 19, 2013.
    13 changes: 13 additions & 0 deletions iepathos_factors.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    from math import sqrt

    ### FIND FACTORS
    """
    Fastest factorization algorithm? Uses tuples instead of lists
    and sqrt imported to the namespace over exponentiation.
    """
    def factors(n):
    return set(x for tup in ([i, n//i]
    for i in range(1, int(sqrt(n))+1) if n % i == 0) for x in tup)