diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-25 08:55:30 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-25 08:55:30 -0500 |
| commit | 99c4b2d9980dd14e8c43ffbf00660047335ada4b (patch) | |
| tree | 400aac6fc6694327454ba91e6fe6973282106769 /radix_info.go | |
| parent | 24a8dde3a708b0cd95007d940e8957b21df40055 (diff) | |
Limit MTC calculation to < 2^32
This ensures the output can fit into a uint64. Also, calculating it at
this stage is slow, and not calculating it can make the program nearly
instant even for very large numbers!
Diffstat (limited to 'radix_info.go')
| -rw-r--r-- | radix_info.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/radix_info.go b/radix_info.go index f3aecce..daf62df 100644 --- a/radix_info.go +++ b/radix_info.go @@ -24,8 +24,13 @@ func main() { fmt.Println("2345 Rank:", factors.BasicRank(n)) if n < 1<<32 { printTypeMessage(factors.Type(uint32(n))) + // MTC(n) < n^2, so n < 2^32 ensures it fits in a uint64 + fmt.Println("Multiplication Table Complexity:", + factors.MTC(uint64(n))) + } else { + fmt.Printf("Multiplication Table Complexity ≤ %.4g\n", + float32(n) * float32(n - 2)) } - fmt.Println("Multiplication Table Complexity:", factors.MTC(n)) fmt.Printf("Natural Logarithm: %.2f\n", math.Log(float64(n))) } else { fmt.Println("Argument must be an integer above 1.") |
