summaryrefslogtreecommitdiff
path: root/factors/score.go
diff options
context:
space:
mode:
Diffstat (limited to 'factors/score.go')
-rw-r--r--factors/score.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/factors/score.go b/factors/score.go
index b47aac4..9288e8f 100644
--- a/factors/score.go
+++ b/factors/score.go
@@ -1,5 +1,7 @@
package factors
+import "math"
+
// Score returns a "factor score" equal to the sum of the reciprocoals
// of the number n's factors.
// Rationale:
@@ -17,7 +19,7 @@ package factors
// a factor's score is the probability a random number is divisible by it.
func Score(n uint) float64 {
if n == 0 {
- panic("Cannot get factor score of 0.")
+ return math.NaN()
}
factorSum := uint(0)
@@ -27,9 +29,11 @@ func Score(n uint) float64 {
return float64(factorSum) / float64(n)
}
-// BasicRank returns a rank describing how well a base handles the simplest
-// fractions (1/2, 1/3, 1/4 and 1/5)
-// also known as 2345 Rank
+// BasicRank returns a rank describing how well a radix handles the simplest
+// fractions (1/2, 1/3, 1/4 and 1/5). Zero and one are not true radices,
+// but because this rank otherwise only depends on a radix's remainder
+// mod 60, they have the same ranks as 60 and 61 (A+, F~).
+// Also known as 2345 Rank.
func BasicRank(n uint) string {
var firstRank, secondRank string
if n%2 == 0 {