summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2023-09-04 18:51:26 -0500
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2023-09-04 18:54:13 -0500
commita663fa77cde6ad48f29abd6973211c179ff32464 (patch)
tree757345be6e80e5742d4fe63dd6ebf5b7d66f7a08
parent5978972b06fb5e29723e4bab61bdfee74b42b126 (diff)
Increase detail of digit map neighbours
It now distinguishes between omega (factors of r - 1), alpha (factors of r + 1) and the rest. The previous categorization determined whether or not totatives and semitotatives have simple patterns; this new categorization determines which simple patterns they follow)
-rw-r--r--factors/digit_map.go25
-rw-r--r--factors/factors_test.go50
-rw-r--r--print_digit_map.go2
3 files changed, 55 insertions, 22 deletions
diff --git a/factors/digit_map.go b/factors/digit_map.go
index e78cce0..db562db 100644
--- a/factors/digit_map.go
+++ b/factors/digit_map.go
@@ -12,9 +12,18 @@ type TotativeType uint8
const (
// This number does not have any totative factors
Regular TotativeType = iota
+ // This number's totative part is divisible by (r - 1)
+ // - this gives it the simplest possible decimal expansion
+ // for a non-regular (1 digit repeating) and a simple divisibility
+ // test (sum digits, like 3 or 9 in decimal)
+ Omega
+ // This number's totative part is divisible by (r + 1)
+ // - this makes it slightly more complicated than omega
+ Alpha
// This number's totative part is divisible by (r^2 - 1)
- // - this makes it easier to work with
- Neighbour
+ // but not (r + 1) or (r - 1)
+ // - these totatives straddle the line between simple and complex
+ Pseudoneighbour
// This number's totative part is not divisible by (r^2 - 1)
// - it will not be nice to work with
Opaque
@@ -56,7 +65,11 @@ func (dt DigitType) String() string {
tString = "0"
case Regular:
tString = "R"
- case Neighbour:
+ case Omega:
+ tString = "ω"
+ case Alpha:
+ tString = "α"
+ case Pseudoneighbour:
tString = "N"
case Opaque:
tString = "P"
@@ -100,8 +113,12 @@ func calcTotativeType(totative, radix uint) TotativeType {
return Zero
case totative == 1:
return Regular
+ case (radix-1)%totative == 0:
+ return Omega
+ case (radix+1)%totative == 0:
+ return Alpha
case (radix*radix-1)%totative == 0:
- return Neighbour
+ return Pseudoneighbour
default:
return Opaque
}
diff --git a/factors/factors_test.go b/factors/factors_test.go
index 6b56e25..af91e70 100644
--- a/factors/factors_test.go
+++ b/factors/factors_test.go
@@ -192,27 +192,43 @@ func TestType(t *testing.T) {
// ====== DIGIT MAP TESTS ======
var (
- zt = zeroType // 00 - zero
- ot = oneType // 0R - one
- ft = DigitType{1, Regular} // 1R - factors
- rt = DigitType{2, Regular} // 2R - regulars (index 2)
- nt = DigitType{0, Neighbour} // 0N - neighbours
- pt = DigitType{0, Opaque} // 0P - opaque totatives
+ zt = zeroType // 00 - zero
+ ot = oneType // 0R - one
+ ft = DigitType{1, Regular} // 1R - factors
+ rt = DigitType{2, Regular} // 2R - regulars (index 2)
+ wt = DigitType{0, Omega} // 0ω - omega neighbours
+ at = DigitType{0, Alpha} // 0α - alpha neighbours
+ nt = DigitType{0, Pseudoneighbour} // 0N - neighbour-like
+ pt = DigitType{0, Opaque} // 0P - opaque totatives
)
var digitMapCases = map[uint][]DigitType{
2: []DigitType{zt, ot},
- 3: []DigitType{zt, ot, nt},
- 4: []DigitType{zt, ot, ft, nt},
- 5: []DigitType{zt, ot, nt, nt, nt},
- 6: []DigitType{zt, ot, ft, ft, rt, nt},
- 8: []DigitType{zt, ot, ft, nt, ft, pt, DigitType{1, Neighbour}, nt},
- 10: []DigitType{zt, ot, ft, nt, rt, ft, DigitType{1, Neighbour}, pt,
- DigitType{3, Regular}, nt},
+ 3: []DigitType{zt, ot, wt},
+ 4: []DigitType{zt, ot, ft, wt},
+ 5: []DigitType{zt, ot, wt, at, wt},
+ 6: []DigitType{zt, ot, ft, ft, rt, wt},
+ 8: []DigitType{zt, ot, ft, at, ft, pt, DigitType{1, Alpha}, wt},
+ 10: []DigitType{zt, ot, ft, wt, rt, ft, DigitType{1, Omega}, pt,
+ DigitType{3, Regular}, wt},
+ 11: []DigitType{zt, ot, wt, at, at, wt, at, pt, nt, pt, wt},
12: []DigitType{zt, ot, ft, ft, ft, pt, ft, pt, rt, rt,
- DigitType{1, Opaque}, nt},
- 16: []DigitType{zt, ot, ft, nt, ft, nt, DigitType{1, Neighbour}, pt,
- ft, pt, DigitType{1, Neighbour}, pt, DigitType{1, Neighbour},
- pt, DigitType{1, Opaque}, nt},
+ DigitType{1, Opaque}, wt},
+ 16: []DigitType{zt, ot, ft, wt, ft, wt, DigitType{1, Omega}, pt,
+ ft, pt, DigitType{1, Omega}, pt, DigitType{1, Omega},
+ pt, DigitType{1, Opaque}, wt},
+ 17: []DigitType{zt, ot, wt, at, wt, pt, at, pt, wt, at,
+ pt, pt, nt, pt, pt, pt, wt},
+ 19: []DigitType{zt, ot, wt, wt, at, at, wt, pt, nt, wt,
+ at, pt, nt, pt, pt, nt, pt, pt, wt},
+ 22: []DigitType{zt, ot, ft, wt, rt, pt, DigitType{1, Omega}, wt,
+ DigitType{3, Regular}, pt, DigitType{1, Opaque}, ft,
+ DigitType{2, Omega}, pt, DigitType{1, Omega}, pt,
+ DigitType{4, Regular}, pt, DigitType{1, Opaque}, pt,
+ DigitType{2, Opaque}, wt},
+ 24: []DigitType{zt, ot, ft, ft, ft, at, ft, pt, ft, rt,
+ DigitType{1, Alpha}, pt, ft, pt, DigitType{1, Opaque},
+ DigitType{1, Alpha}, rt, pt, rt, pt, DigitType{1, Alpha},
+ DigitType{1, Opaque}, DigitType{1, Opaque}, wt},
}
func TestDigitMap(t *testing.T) {
diff --git a/print_digit_map.go b/print_digit_map.go
index b878a51..1f5ad64 100644
--- a/print_digit_map.go
+++ b/print_digit_map.go
@@ -66,7 +66,7 @@ func colourString(s string, digitType factors.DigitType) string {
default:
colourBegin = "\x1B[48;5;2m" // other regulars
}
- case factors.Neighbour:
+ case factors.Omega, factors.Alpha, factors.Pseudoneighbour:
if digitType.Regularity() == 0 {
colourBegin = "\x1B[48;5;198m" // neighbourly totatives
} else {