public static void DoTest()
        {
            long[] Result = new long[]
            {
                2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37
            };

            Assert.AreEqual(Result, Sieve.Generate(40));
        }
예제 #2
0
        public static long[] Factor(decimal n)
        {
            long[] pfactors = Sieve.Generate((long)Math.Sqrt(Convert.ToDouble(n)));

            List <long> factors = new List <long>();

            foreach (var item in pfactors)
            {
                while (n % item == 0)
                {
                    factors.Add(item);
                    n /= item;
                }
            }

            return(factors.ToArray());
        }
예제 #3
0
 public static long[] GetCache(decimal n)
 {
     return(Sieve.Generate((long)Math.Sqrt(Convert.ToDouble(n))));
 }