diff options
author | siddharth ravikumar <s@ricketyspace.net> | 2022-11-20 16:07:47 -0500 |
---|---|---|
committer | siddharth ravikumar <s@ricketyspace.net> | 2022-11-20 16:07:47 -0500 |
commit | 73b0bec6c8c2aaf0f8b4e22a60a925881b202a15 (patch) | |
tree | 3482d1c7cae3fc89cd1924092b025b40eba1f93e /lib/cbrt_test.go | |
parent | c14e8eda830099f30e1a9aeb2fd4fdcef9cca94a (diff) |
lib: add `BigIntCubeRoot`
Diffstat (limited to 'lib/cbrt_test.go')
-rw-r--r-- | lib/cbrt_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/cbrt_test.go b/lib/cbrt_test.go index a5722c8..6b3c9f3 100644 --- a/lib/cbrt_test.go +++ b/lib/cbrt_test.go @@ -21,3 +21,17 @@ func TestBigCubeRoot(t *testing.T) { return } } + +func TestBigIntCubeRoot(t *testing.T) { + a := big.NewInt(19683) + acr := BigIntCubeRoot(a) + if acr == nil { + t.Errorf("Could not find cube root of %v\n", a) + return + } + expected := big.NewInt(27) + if big.NewInt(0).Sub(acr, expected).Cmp(big.NewInt(0)) != 0 { + t.Errorf("Could not find cube root of %v (%v)\n", a, acr) + return + } +} |