private static IEnumerable <long> GetFactors(this long x) => StrangeEnumerable.Range(1, x.GetCeiling()) .Where(n => x.IsEvenlyDivisibleBy(n)) .SelectMany(n => n != x / n ? new[] { n, x / n } : new[] { n });
public static bool IsPrime(this long x) => x <= 1 ? false : x <= 3 ? true : !StrangeEnumerable.RangeTwoAndOdd(x.GetCeiling()) .Any(n => x.IsEvenlyDivisibleBy(n));
public static IEnumerable <long> GetPrimeFactors(this long x) => StrangeEnumerable.Range(2, x.GetCeiling()) .Where(n => x.IsEvenlyDivisibleBy(n)) .SelectMany(n => (x / n).IsPrime() ? n.IsPrime() ? n != x / n ? new[] { n, x / n } : new[] { n } : new[] { x / n } : n.IsPrime() ? new[] { n } : new long[] { });