diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-25 08:55:30 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-25 08:55:30 -0500 |
| commit | 99c4b2d9980dd14e8c43ffbf00660047335ada4b (patch) | |
| tree | 400aac6fc6694327454ba91e6fe6973282106769 /factors/factors_test.go | |
| parent | 24a8dde3a708b0cd95007d940e8957b21df40055 (diff) | |
Limit MTC calculation to < 2^32
This ensures the output can fit into a uint64. Also, calculating it at
this stage is slow, and not calculating it can make the program nearly
instant even for very large numbers!
Diffstat (limited to 'factors/factors_test.go')
| -rw-r--r-- | factors/factors_test.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/factors/factors_test.go b/factors/factors_test.go index 12d4384..33727c0 100644 --- a/factors/factors_test.go +++ b/factors/factors_test.go @@ -100,7 +100,7 @@ func TestBasicRank(t *testing.T) { tableTest(t, BasicRank, basicRankCases, stdEquals, "BasicRank") } -var gcdCases = map[struct{ a, b uint }]uint{ +var gcdCases = map[struct{ a, b uint64 }]uint64{ {0, 0}: 0, {1, 1}: 1, {6, 10}: 2, {10, 6}: 2, {12, 20}: 4, {20, 12}: 4, @@ -109,7 +109,7 @@ var gcdCases = map[struct{ a, b uint }]uint{ } // a version of gcd() for testing purposes -func gcdTest(c struct{ a, b uint }) uint { +func gcdTest(c struct{ a, b uint64 }) uint64 { return gcd(c.a, c.b) } @@ -117,7 +117,7 @@ func TestGCD(t *testing.T) { tableTest(t, gcdTest, gcdCases, stdEquals, "gcd") } -var mtcCases = map[uint]uint{ +var mtcCases = map[uint64]uint64{ 2: 0, 3: 0, 4: 2, 5: 10, 6: 8, 7: 28, 8: 26, 9: 42, 10: 42, 11: 88, 12: 52, 13: 130, 14: 100, 15: 116, 16: 138, 18: 146, |
