summaryrefslogtreecommitdiff
path: root/factors/score.go
AgeCommit message (Collapse)Author
2023-11-12Add per-file copyright notices & contact infoAdrien Hopkins
This is the safest thing to do to ensure my software is free while avoiding legal trouble ... hopefully, I'm not a lawyer!
2023-10-09factors: Give all exported members proper godocAdrien Hopkins
2023-10-09Add more tests & fix found bugsAdrien Hopkins
- TotativeDigits was defined incorrectly, previously counted totatives from 0 to r-1, now counts digits from 1 to r. This ensures that len(TotativeDigits(r)) = Totient(r).
2023-09-19factors.Score: Avoid overflow by using math/bigAdrien Hopkins
When using really large numbers, factors.Score could overflow, which would cause an incorrect result. Using arbitrary-precision arithmetic fixes this. I only do so above 2^28, since below then factor sums are guaranteed to not overflow, and normal arithmetic is faster.
2023-09-19factors: refactor code to improve readabilityAdrien Hopkins
2023-09-13factors: Remove most panicsAdrien Hopkins
Panics are not the best way of handling errors in Go. I've replaced panics with default values whenever a sensible one exists. Factors(0) does not have a sensible default value (as every number is a factor of zero), so it still panics.
2023-08-21Add 2345 Score to outputAdrien Hopkins
2023-08-21Add totative ratio and factor score to programAdrien Hopkins