diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-21 09:35:27 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-21 09:56:06 -0500 |
| commit | 547c63fbf0c6dd673e8caf83ea7f9eeb679b5f5c (patch) | |
| tree | 31c07bcab4ffb2c18d287f50d471660cd65bac39 /factors/mtc.go | |
| parent | 30e92c33303535a86e56824b668f46ad0c6261a8 (diff) | |
Add MTC to output
(MTC = Multiplication Table Complexity)
Diffstat (limited to 'factors/mtc.go')
| -rw-r--r-- | factors/mtc.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/factors/mtc.go b/factors/mtc.go new file mode 100644 index 0000000..d008ca3 --- /dev/null +++ b/factors/mtc.go @@ -0,0 +1,19 @@ +package factors + +// MTC returns the multiplication table complexity of a radix n. +// This is an estimate of how difficult it is to learn a radix's +// multiplication table. +func MTC(n uint) uint { + mtc := uint(0) + for i := uint(2); i <= n - 2; i++ { + mtc += n / gcd(i, n) + } + return mtc +} + +func gcd(a, b uint) uint { + for b > 0 { + a, b = b, a % b + } + return a +} |
