diff options
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 +} |
