Exemple #1
0
        public static IEnumerable <long> PrimeNumberBelow(int upperBound)
        {
            yield return(2);

            long num = 3;

            do
            {
                if (Factors.IsPrime(num))
                {
                    yield return(num);
                }
                num += 2;
            } while (num < upperBound);
        }
Exemple #2
0
        public static IEnumerable <long> PrimeNumberNth(int index)
        {
            yield return(2);

            long num = 3;
            int  i   = 1;

            do
            {
                if (Factors.IsPrime(num))
                {
                    yield return(num);

                    i++;
                }
                num += 2;
            } while (i < index);
        }