/* A centrifuge, as you probably know, is a laboratory device used to * separate fluids based on density. The separation is achieved through * centripetal force by spinning a collection of test tubes at high speeds. * This means, the configuration needs to be in balance. * Create a function that takes two numbers as arguments n and k and * returns true if the configuration is balanced and false if it's not. * To check out the formula, look at the resources tab. * Here are the valid configurations for n = 6, k = 2, 3, 4 and 6. * One test tube (k = 1) is never in balance. * One hole (n = 1) is never in balance, even empty. */ std::vector factors(int n){ int z = 2; std::vector output; while (z * z <= n){ if (n % z == 0){ output.push_back(z); n /= z; }else{z++;} } if(n > 1){output.push_back(n);} return output; } // It(test3){Assert::That(cFuge(12, 7), Equals(true));} bool cFuge(int n, int k) { int Sum = 0; // if k or n is one, return false if(1 == k || 1 == n){return false;} if(0 == k){return true;} if(n == k){return true;} // if k and n are even, return true if ((k%2 == 0) && (n%2 == 0)){return true;} std::vector nfactors = factors(n); // find the prime factorization of a number and see if the sum of those numbers is equal to k for(int i = 0;i kfactors = factors(k); // if n & k share a common factor, return true. for(int i = 0;i