-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If every prime factor is prime number then, how 1️⃣ is a prime factor? ⚠️ ⚠️ ⚠️ #7
Open
2 tasks done
Comments
I just saw one issue there which is resolved: But still it's reproducing |
Completely freezing compilation when we pass
|
Hi @janaindrajit #Calculates the lowest prime factor by default
def factor(num:int)->int:
'''
Parameters
----------
num : int
Input number
Returns
-------
int
Lowest prime factor
'''
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
return 3 # dakra added
else:
for i in range(6, int(sqrt(num))+7, 6): # dakra Primes > 3 are all either
if num%(i-1)==0: return i-1 # dakra 5 mod 6 or
if num%(i+1)==0: return i+1 # dakra 1 mod 6
# dakra saving all the tests for number which are 3 mod 6.
else:
return num def factors(num:int)->list:
'''
Parameters
----------
num : int
Given number
Returns
-------
list
List of prime factors
'''
fact=factor(num)
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 [] |
Issue is fixed in this branch Commit: Please verify once @janaindrajit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We know every prime factor of a number is a prime number.
By definition, a prime factor is a prime number that divides the original number exactly and without a remainder. If a number is a prime factor, it must be a prime number.
This is the definition according to your documentation:
primes.factor(n)
returns the lowest prime factor of n.primes.facors(n)
returns all the prime factors of n with multiplicity.I am trying to find prime factor of
1
.I am surprised it's returning
1
This is my code:
Output:
We know, 1 is neither a prime nor a composite number. Prime numbers are defined as positive integers greater than 1 that are only divisible by 1 and themselves, and 1 is not greater than 1.
Please resolve this issue.
The text was updated successfully, but these errors were encountered: