From ebdc5107b8b2bd69a65a34a6276fc64b84d210ec Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Tue, 5 Sep 2023 11:15:28 -0500 Subject: Remove totative ratio from factors API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This value can easily be calculated as φ(r)/r. There is no need to have this now that I have a function φ(r) (renamed to its mathematical name, Totient). I removed totative ratio instead of totient because, while it is more important, totient is an integer while totative ratio is a float. This means that the totative ratio can be calculated exactly from the totient, but not the other way round. --- factors/totative.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'factors/totative.go') diff --git a/factors/totative.go b/factors/totative.go index 7a4bebe..680cc26 100644 --- a/factors/totative.go +++ b/factors/totative.go @@ -1,18 +1,8 @@ package factors -// TotativeRatio calculates the fraction of numbers that +// Totient calculates the number of numbers less than n that // are totatives of n (share no factors with n) -func TotativeRatio(n uint) float64 { - if n == 0 { - panic("0 has no totative ratio!") - } - - return float64(TotativeCount(n)) / float64(n) -} - -// TotativeCount calculates the number of numbers less than n that -// are totatives of n (share no factors with n) -func TotativeCount(n uint) uint { +func Totient(n uint) uint { if n == 0 { return 0 } -- cgit v1.2.3