had a duplicate function name. fixed

This commit is contained in:
Andrew S Erwin 2021-11-18 17:17:50 -06:00
parent d20c5686d1
commit 79dec897d4
2 changed files with 5 additions and 5 deletions

View File

@ -6,12 +6,12 @@
* @param int $dec number to convert
* @return string
*/
function decimalToBinary(int $dec, string $result = "")
function decToBin(int $dec, string $result = "")
{
if($dec == 0) return $result;
$result = (string)($dec % 2) . $result;
return decimalToBinary($dec / 2, $result);
return decToBin($dec / 2, $result);
}
print decimalToBinary(200);
print decToBin(200);

View File

@ -10,7 +10,7 @@ class DecimalToBinaryTest extends TestCase
{
public function testDecimalToBinary()
{
assertEquals(decimalToBinary(7), '111');
assertEquals(decimalToBinary(5), '101');
assertEquals(decToBin(7), '111');
assertEquals(decToBin(5), '101');
}
}