public static MultiSet <long> Factorize(this long n) { var factors = new MultiSet <long>(); for (long i = 2; i *i <= n; i++) { while (n % i == 0) { n /= i; factors[i]++; } } if (n > 1) { factors.Add(n); } return(factors); }
public MultiSet(MultiSet <T> source) : this(source.occurrence) { }