Loading...
Loading...
Loading...
Write a recursive function that returns the binary form of a non-negative integer as text, without using bin or format. Print it.
Example
Input
10
Output
1010
1010 in binary.
Try the problem first. Open one hint at a time.
The last bit is n % 2 and the rest is n // 2.
Handle n < 2 as the base case, returning str(n).
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor