From 73b0bec6c8c2aaf0f8b4e22a60a925881b202a15 Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Sun, 20 Nov 2022 16:07:47 -0500 Subject: lib: add `BigIntCubeRoot` --- lib/cbrt_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/cbrt_test.go') 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 + } +} -- cgit v1.2.3