summaryrefslogtreecommitdiff
path: root/factors/totative.go
diff options
context:
space:
mode:
Diffstat (limited to 'factors/totative.go')
-rw-r--r--factors/totative.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/factors/totative.go b/factors/totative.go
index 558f0f0..3a1f635 100644
--- a/factors/totative.go
+++ b/factors/totative.go
@@ -8,10 +8,11 @@ func TotativeRatio(n uint) float64 {
}
primeFactorization := PrimeFactorize(n)
+ num, denom := uint(1), uint(1)
- totativeRatio := 1.0
for p := range primeFactorization.exponents {
- totativeRatio *= float64(p - 1) / float64(p)
+ num *= p - 1
+ denom *= p
}
- return totativeRatio
+ return float64(num) / float64(denom)
}