Skip to content
Snippets Groups Projects
Commit 86e5d28f authored by Antony Nixen Raj's avatar Antony Nixen Raj
Browse files

Prime Factors

parent 16bb5234
No related branches found
No related tags found
No related merge requests found
package NumberSystem;
public class PrimeFactors {
public int[] AllPrimeFactors(int N)
{
int sz=0;
for(int i=2;i<=N;i++){
if(N%i==0 && isPrime(i)){
sz++;
}
}
int a[]=new int[sz];
for(int i=2,j=0;i<=N;i++){
if(N%i==0 && isPrime(i)){
a[j++]=i;
}
}
return a;
}
static boolean isPrime(int n) {
for(int i=2;i<n;i++){
if(n%i==0)
return false;
}
return true;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment