Exemplo n.º 1
0
        private int SumTwoToTheOmegaSimple(long x, int limit)
        {
            var mobius  = new MobiusCollection(limit + 1, 2 * threads);
            var sum     = 0;
            var nLast   = (long)0;
            var tauLast = 0;

            for (var d = 1; d <= limit; d++)
            {
                var mu = mobius[d];
                if (mu != 0)
                {
                    var n   = x / ((long)d * d);
                    var tau = n == nLast ? tauLast : TauSum((ulong)n);
                    if (mu == 1)
                    {
                        sum += tau;
                    }
                    else
                    {
                        sum += 4 - tau;
                    }
                    tauLast = tau;
                    nLast   = n;
                }
            }
            return(sum);
        }
Exemplo n.º 2
0
        public BigInteger Evaluate(BigInteger n)
        {
            t3Map.Clear();
            var jmax = IntegerMath.FloorLog(n, 2);
            var dmax = IntegerMath.FloorRoot(n, 3);

            mobius = new MobiusCollection((int)(IntegerMath.Max(jmax, dmax) + 1), 0);
            return(Pi3(n));
        }