Prime Factorization
void PrimeFact( int n, int *factors, int *factCount, int &len){ int i,count, sqrtN; sqrtN = (int) sqrt( (double) n ) + 1; for(i = 0; prime[i] < sqrtN ; i++)if(!(n%prime[i])){ factors[len] = prime[i]; count = 0; while(!(n%prime[i]))n/=prime[i], count++; factCount[len++] = count; sqrtN = (int) sqrt( (double) n ) + 1; } if(n>1)factors[len] = n, factCount[len++] = 1; }