public static class A324257 { public static bool IsA324257(long n, long[] distinctFactors) { bool stat = true; string nStr = n.ToString(); bool[] digitUsed = new bool[nStr.Length]; foreach (long p in distinctFactors) { if (!nStr.Contains(p.ToString())) { // n doesn't contain this factor stat = false; break; } else { // all digits in n need to be used int index = -1; while ((index = nStr.IndexOf(p.ToString(), index + 1)) > -1) { for (int offset = 0; offset < p.ToString().Length; offset++) { digitUsed[index + offset] = true; } } } } foreach (bool b in digitUsed) { if (!b) { stat = false; break; } } return stat; } }