Beispiel #1
0
        private static long[] FindPrimes(long[] strongs, IPrimeDecider decider)
        {
            var list = new List <long>();

            foreach (var number in strongs)
            {
                for (var digit = 1; digit < 10; digit += 2)
                {
                    var newNumber = number.ToString().Plus(digit).ToLong();
                    if (newNumber.IsPrime(decider))
                    {
                        list.Add(newNumber);
                    }
                }
            }

            return(list.ToArray());
        }
Beispiel #2
0
 private static bool IsStrong(long number, IPrimeDecider decider) => number.IsHarshad() && (number / number.SumDigits()).IsPrime(decider);
Beispiel #3
0
 public static bool IsComposite(this long value, IPrimeDecider decider) => !decider.IsPrime(value);
Beispiel #4
0
 public static bool IsPrime(this long value, IPrimeDecider decider) => decider.IsPrime(value);