コード例 #1
0
        /// <summary>
        /// Computes the Product of the prime numbers in the given sieveRange.
        /// </summary>
        /// <param name="range">The sieveRange of the enumeration.</param>
        /// <returns>The Product of the prime numbers in the enumeration.
        /// </returns>
        public XInt GetPrimorial(PositiveRange range)
        {
            int start, size;
            var pc = new PrimeCollection(this, range);

            if (pc.GetSliceParameters(out start, out size))
            {
                return(XInt.One);
            }

            return(XMath.Product(this.primes, start, size));
        }
コード例 #2
0
        /// <summary>
        /// Computes the Product of the prime numbers in the given sieveRange
        /// primes[start]*primes[start+increment]*primes[start+2*increment]*...
        /// </summary>
        /// <param name="low">Lower bound of the sieveRange of the enumeration.</param>
        /// <param name="high">Higher bound of the sieveRange of the enumeration.</param>
        /// <returns>The Product of the prime numbers in the enumeration.</returns>
        public XInt GetPrimorial(int low, int high, int increment)
        {
            if (increment == 1)
            {
                return(this.GetPrimorial(new PositiveRange(low, high)));
            }

            var range = new PositiveRange(low, high);
            var pc = new PrimeCollection(this, range, increment);
            int start, size;

            if (pc.GetSliceParameters(out start, out size))
            {
                return(XInt.One);
            }

            return(XMath.Product(this.primes, start, size, increment));
        }