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
Fun exercise!
difficult that I intended it to be.
Wait until you see the guy who solved it with a +41k code size.
Solution Comments
Show commentsProblem Recent Solvers4566
Suggested Problems
-
Remove the polynomials that have positive real elements of their roots.
1705 Solvers
-
Who knows the last digit of pi?
673 Solvers
-
Back to basics 20 - singleton dimensions
270 Solvers
-
Make a vector of prime numbers
801 Solvers
-
There are 10 types of people in the world
1156 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!