Prime Factors of a Number
def primeFactors(n):
global factors
if(n==1):
return
elif((n%factors)== 0):
print(factors)
primeFactors(n//factors)
else:
factors+=1
primeFactors(n)
factors = 2
Prime Factors of a Number
def primeFactors(n):
global factors
if(n==1):
return
elif((n%factors)== 0):
print(factors)
primeFactors(n//factors)
else:
factors+=1
primeFactors(n)
factors = 2
Prime factors of a number
public List<Integer> factorsOf(int n) {
ArrayList<Integer> factors = new ArrayList<>();
for (int d = 2; n > 1; d++)
for (; n % d == 0; n /= d)
factors.add(d);
return factors;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us