Exemple #1
0
        static IEnumerable <BigInteger> squareDivisor(BigInteger num)
        {
            var solutions = new BigPrime().Factors(num)
                            .ToLookup(p => p)
                            .SelectMany(x => Enumerable.Repeat(x.Key, x.Count() / 2))
                            .ToList()
                            .Backtrack(
                BigInteger.One,
                (prod, item, i) => prod * item,
                prod => true
                );

            solutions.BacktrackingModel = BacktrackingModel.Combination;
            solutions.Distinct          = true;
            solutions.ContinueOnYielded = true;
            return(solutions.SelectResults());
        }
Exemple #2
0
 public BigDivisor(BigInteger num, BigPrime prime)
 {
     _factors = prime.Factors(num).ToLookup(x => x);
     _num     = num;
     _prime   = prime;
 }