Skip to content

Commit

Permalink
Added factor.py
Browse files Browse the repository at this point in the history
factor.py: finds all factors of a positive integer passed to it as an argument on the command line
  • Loading branch information
ghemsley authored Sep 4, 2017
1 parent 4a312df commit 4e4462c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions factor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/python3

def factor(__n):

__factorList = []

for __i in range(1,__n+1):
if __n % __i == 0:
__factorList.append(__i)
return __factorList

def main():

import argparse
from sys import exit

__parser = None
__args = None

__parser = argparse.ArgumentParser()
__parser.add_argument("number", help="Number to factor", type=int)
__args = __parser.parse_args()
print(str(factor(__args.number)))
exit()

main()

0 comments on commit 4e4462c

Please sign in to comment.