3
$\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$
  • 2
    $\begingroup$ Tuples[{0, 1}, m]? $\endgroup$ – kglr Sep 29 at 9:37
4
$\begingroup$

You can also use Tuples:

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

enter image description here

| improve this answer | |
$\endgroup$
4
$\begingroup$

Look up IntegerDigits.

m = 5;

IntegerDigits[Range[0, 2^m - 1], 2, m]
| improve this answer | |
$\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.