- // Create a function that takes a number as its argument and
- // returns an array of all its factors.
- std::vector<int> factorize(int n) {
- std::vector<int> results={};
- for (int a=1;a<=n;a++){
- // check to see if it is a factor. and then store the factor
- if (n%a==0) {
- results.push_back(a);
- }
-
- }
- return results;
- }
|