Dsa
Recursion
Easy
Generate Binary Numbers
Write a program to generate binary numbers from 1 to a given integer n. Input n and output all binary numbers in order from 1 to n, each on a new line.
Example:
Input:
5
Output:
1
10
11
100
101
Key concepts
recursionstringsbinary
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now