Skip to content

Commit

Permalink
Fixed Issue: primePy/issues/7 & 8
Browse files Browse the repository at this point in the history
  • Loading branch information
artbindu committed Jan 9, 2024
1 parent 9c98276 commit fe9aa90
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions primes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def factor(num:int)->int:
Lowest prime factor
'''
if num == 1:
return 2
if num == 1 or num <= 0:
return None
if num==2 or num%2==0:
return 2
if num==3 or num%3==0: # dakra added
Expand Down Expand Up @@ -71,13 +71,16 @@ def factors(num:int)->list:
'''
fact=factor(num)
new_num=num//fact
factors=[fact]
while new_num!=1:
fact=factor(new_num)
factors.append(fact)
new_num//=fact
return factors
if(fact) :
new_num=num//fact
factors=[fact]
while new_num!=1:
fact=factor(new_num)
factors.append(fact)
new_num//=fact
return factors
else :
return []

def phi(num:int)->int:
'''
Expand Down

0 comments on commit fe9aa90

Please sign in to comment.