4
$\begingroup$

Imagine I have a sequence of M integers each of which is either zero or one. How do I generate a sequence of all such 2^M sequences?

$\endgroup$
0
5
$\begingroup$

You can also use Tuples:

m = 5;
Tuples[{0, 1}, m]

enter image description here

$\endgroup$
4
$\begingroup$

Look up IntegerDigits.

m = 5;

IntegerDigits[Range[0, 2^m - 1], 2, m]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.