mirror of
https://github.com/TheAlgorithms/PHP.git
synced 2025-01-17 07:08:13 +01:00
had a duplicate function name. fixed
This commit is contained in:
parent
d20c5686d1
commit
79dec897d4
@ -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);
|
@ -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');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user