logo CodeStepByStep logo


Language/Type: PHP binary recursion

Write a recursive function named print_binary that accepts an integer parameter and prints that number's representation in binary (base 2). For example, the call of print_binary(43) should print 101011 .

If the integer is negative, print the binary representation preceded by a minus sign. For example, the call of print_binary(-6) should print -110 .

Function: Write a PHP function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.