summaryrefslogtreecommitdiff
path: root/factor_info.go
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2025-09-22 16:44:29 -0500
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2025-09-22 16:46:05 -0500
commitbec087c3855f1641ac3681d56c9f8247aa556d2e (patch)
tree19b07482d8519326954b8a1acac310ccc4b1847c /factor_info.go
parentd3fdb797db81ab81c4f91dd88d24723a88b39c2e (diff)
Add option to show logarithmic RC
This makes finding the RC of prime powers multiplication instead of exponentation, which is much easier to do mentally.
Diffstat (limited to 'factor_info.go')
-rw-r--r--factor_info.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/factor_info.go b/factor_info.go
index 638e333..ae3b60a 100644
--- a/factor_info.go
+++ b/factor_info.go
@@ -68,6 +68,8 @@ type factorInfo struct {
// The memorization for the product of prime powers
// is less than the memorization of worst part of the product.
PrimeRegularComplexities map[uint]float64
+ // If true, the above field is the log2 of its true value.
+ LogRegularComplexities bool
}
const (
@@ -114,11 +116,17 @@ func getFactorInfo(a args) *factorInfo {
totativeRatio := float64(totativeCount) / float64(radix)
var prcs = factors.PrimeRegularComplexities(radix)
+ if a.LogRegularComplexities {
+ for regular := range prcs {
+ prcs[regular] = math.Log2(prcs[regular])
+ }
+ }
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, prcs}
+ mtc_ptr, math.Log2(float64(radix)), digitMap, prcs,
+ a.LogRegularComplexities}
}
func (fi *factorInfo) writeTo(w io.Writer) {
@@ -148,7 +156,11 @@ 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: ")
+ if fi.LogRegularComplexities {
+ fmt.Fprint(w, "log2(Prime Regular Complexities): ")
+ } else {
+ fmt.Fprint(w, "Prime Regular Complexities: ")
+ }
writePRCMap(w, fi.PrimeRegularComplexities)
fmt.Fprintln(w)
if len(fi.DigitMap) > 0 {