1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package main
import (
"aphopkins/radix_info/factors"
"fmt"
"math"
"os"
"slices"
"strconv"
)
func main() {
if len(os.Args) > 1 {
if n, err := strconv.ParseUint(os.Args[1], 0, 0); err == nil {
if n > 1 {
n := uint(n)
fmt.Println(n, "=", factors.PrimeFactorize(n))
n_factors := factors.Factors(n)
slices.Sort(n_factors)
factorScore := factors.Score(n)
fmt.Printf("Factors: %v (Score: %.2f)\n", n_factors, factorScore)
fmt.Printf("Totative Ratio: %03.1f%%\n",
factors.TotativeRatio(n)*100.0)
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.Printf("Natural Logarithm: %.2f\n", math.Log(float64(n)))
} else {
fmt.Println("Argument must be an integer above 1.")
}
} else {
fmt.Printf("Argument must be an integer above 1 [%v].\n", err)
}
} else {
fmt.Println("Please provide an argument (radix to study).")
}
}
func printTypeMessage(t factors.NumberType) {
switch t {
case factors.ColossallyAbundant:
fmt.Println("This radix is colossally abundant!")
case factors.Superabundant:
fmt.Println("This radix is superabundant.")
case factors.OrderedExponent:
fmt.Println("This radix has ordered exponents.")
case factors.Practical:
fmt.Println("This radix is practical.")
}
}
|