Problem 34. Binary numbers
Given a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n-1. Each row of the matrix represents one binary number. For example, if n = 3, then your code could return
>> binary_numbers(3)
ans =
1 1 1 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 1 0 1 0 1
The order of the rows does not matter.
Solution Stats
Problem Comments
-
11 Comments
Show
8 older comments
Anudeep
on 9 Nov 2022
Fun exercise!
Riya
on 10 Nov 2022
difficult that I intended it to be.
Yacine
on 5 Oct 2024
Wait until you see the guy who solved it with a +41k code size.
Solution Comments
Show commentsGroup

Basics - Binary Logic
- 10 Problems
- 958 Finishers
- Find the longest sequence of 1's in a binary sequence.
- Convert given decimal number to binary number.
- Find out sum and carry of Binary adder
- Binary numbers
- Given an unsigned integer x, find the largest y by rearranging the bits in x
- Bit Reversal
- Relative ratio of "1" in binary number
- Binary code (array)
- Converting binary to decimals
- There are 10 types of people in the world
Problem Recent Solvers4553
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!