From 564e53cdd4d6fc8b611d59c2c19af42864e6ece4 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Mon, 7 Aug 2023 16:34:47 -0500 Subject: Add totative ratio and factor score to program --- radix_info.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'radix_info.go') 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.") } -- cgit v1.2.3