1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //http://bhsmath.tistory.com/52 //https://kldp.org/node/36453 vector<int> PrimeFactorization(int n) { vector<int> factors; int max = (int)sqrt(n); for (int factor = 2; factor <= max; factor++) { while (n % factor == 0) { factors.push_back(factor); n /= factor; } } if (n > 1) { factors.push_back(n); } return factors; } |
댓글 없음:
댓글 쓰기