Beispiel #1
0
        //prefectchecker should have a method that returns a boolean indicating whether a number is prefect

        public static bool isPerfect(int x)
        {
            if (x == 0)
            {
                return(false);
            }
            int[] factors = FactorFinder.GetFactors(x);
            int   sum     = 0;

            for (int i = 0; i < factors.Length - 1; i++)
            {
                sum += factors[i];
            }
            return(sum == x);
        }
Beispiel #2
0
 public static bool isPrime(int x)
 {
     return(FactorFinder.GetFactors(x).Length == 2);
 }