Esempio n. 1
0
        public int primeFactor()
        {
            prime primeObj = new prime();

            int[] primes      = primeObj.primes(N);
            int[] primeCounts = new int[primes.Length];
            int   maxPrime    = (int)Math.Round(Math.Sqrt(N));

            for (int i = 0; i < primes.Length; i++)
            {
                if (N % primes[i] == 0)
                {
                    primeCounts[i]++;
                }
            }
            if (primeCounts[primes.Length - 1] == 1)
            {
                return(N);
            }
            int primeProduct = 1;

            for (int i = 0; i < primes.Length - 1; i++)
            {
                if (primeCounts[i] != 0)
                {
                    primeProduct *= primes[i];
                }
            }
            return(primeProduct);
        }
Esempio n. 2
0
File: Prime.cs Progetto: 0xCM/arrows
 => valid = demand(prime(n.value));