diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-07 16:34:47 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-21 09:56:04 -0500 |
| commit | 564e53cdd4d6fc8b611d59c2c19af42864e6ece4 (patch) | |
| tree | e48090eb1bc0162c346f7f63ed10305eec778fa8 /radix_info.go | |
| parent | b4bdd6146962d8dde391f09b2cdda9553cb44bde (diff) | |
Add totative ratio and factor score to program
Diffstat (limited to 'radix_info.go')
| -rw-r--r-- | radix_info.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/radix_info.go b/radix_info.go index 770fd42..4194a2c 100644 --- a/radix_info.go +++ b/radix_info.go @@ -12,12 +12,16 @@ func main() { if len(os.Args) > 1 { if n, err := strconv.ParseUint(os.Args[1], 0, 0); err == nil { if n > 1 { - fmt.Printf("%d = %s\n", n, factors.PrimeFactorize(uint(n))) - n_factors := factors.Factors(uint(n)) + n := uint(n) + fmt.Printf("%d = %s\n", n, factors.PrimeFactorize(n)) + n_factors := factors.Factors(n) sort.Slice(n_factors, func(i, j int) bool { return n_factors[i] < n_factors[j] }) - fmt.Printf("Factors: %v\n", 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) } else { fmt.Println("Argument must be an integer above 1.") } |
