File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
src/test/java/com/thealgorithms/maths Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 66
77/**
88 * Test case for Power using Recursion
9- * @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi )
9+ * @author Vinayak (https://github.com/Vinayak-v12 )
1010 */
1111
1212class PowerUsingRecursionTest {
1313
1414 @ Test
1515 void testPowerUsingRecursion () {
16- assertEquals (32.0 , PowerUsingRecursion .power (2.0 , 5 ));
17- assertEquals (97.65625 , PowerUsingRecursion .power (2.5 , 5 ));
18- assertEquals (81 , PowerUsingRecursion .power (3 , 4 ));
16+ // exponent = 0
17+ assertEquals (1.0 , PowerUsingRecursion .power (5.0 , 0 ));
18+
19+ // exponent = 1
20+ assertEquals (5.0 , PowerUsingRecursion .power (5.0 , 1 ));
21+
22+ // negative exponent
23+ assertEquals (0.25 , PowerUsingRecursion .power (2.0 , -2 ));
24+
25+ // another negative exponent
26+ assertEquals (0.5 , PowerUsingRecursion .power (2.0 , -1 ));
1927 }
28+
2029}
You can’t perform that action at this time.
0 commit comments