diff options
Diffstat (limited to 'factor_info.go')
| -rw-r--r-- | factor_info.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/factor_info.go b/factor_info.go index 637bde2..638e333 100644 --- a/factor_info.go +++ b/factor_info.go @@ -63,6 +63,11 @@ type factorInfo struct { // reciprocoal has and what patterns are in its row of the multiplication // table. DigitMap []factors.DigitType + // The complexity of each prime factor. + // The amount of numbers to memorize for testing p^e is around RC(p)^e. + // The memorization for the product of prime powers + // is less than the memorization of worst part of the product. + PrimeRegularComplexities map[uint]float64 } const ( @@ -108,10 +113,12 @@ func getFactorInfo(a args) *factorInfo { totativeCount := factors.Totient(radix) totativeRatio := float64(totativeCount) / float64(radix) + var prcs = factors.PrimeRegularComplexities(radix) + return &factorInfo{radix, factors.PrimeFactorize(radix), r_factors, factors.Score(radix), totativeCount, totativeRatio, totativeDigits, factors.BasicRank(radix), factors.Type(radix), - mtc_ptr, math.Log2(float64(radix)), digitMap} + mtc_ptr, math.Log2(float64(radix)), digitMap, prcs} } func (fi *factorInfo) writeTo(w io.Writer) { @@ -141,6 +148,9 @@ func (fi *factorInfo) writeTo(w io.Writer) { fmt.Fprintf(w, "Base-2 Logarithm: %.3f\n", fi.Log2) fmt.Fprintf(w, "Number Length: %.4f×Decimal\n", 1/math.Log10(float64(fi.Radix))) + fmt.Fprint(w, "Prime Regular Complexities: ") + writePRCMap(w, fi.PrimeRegularComplexities) + fmt.Fprintln(w) if len(fi.DigitMap) > 0 { writeDigitMap(w, fi.DigitMap) } @@ -193,3 +203,22 @@ func typeAbbrev(t factors.CompositenessType) string { panic("Should not be possible to get here.") } } + +func writePRCMap(w io.Writer, prcs map[uint]float64) { + var first = true + var primeFactors = make([]uint, 0, len(prcs)) + for p := range prcs { + primeFactors = append(primeFactors, p) + } + sort.Slice(primeFactors, func(i, j int) bool { + return primeFactors[i] < primeFactors[j] + }) + + for _, p := range primeFactors { + if !first { + fmt.Fprintf(w, ", ") + } + first = false + fmt.Fprintf(w, "%d: %.4f", p, prcs[p]) + } +} |
