Skip to content

Instantly share code, notes, and snippets.

@tail-call
Created July 12, 2020 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tail-call/8fa8747b192c68abaf10f9cdade7f7e6 to your computer and use it in GitHub Desktop.
Save tail-call/8fa8747b192c68abaf10f9cdade7f7e6 to your computer and use it in GitHub Desktop.
I wanted a very big sequence of primes but why
const seq1 = [2, 3];
const seq2 = [2, 3, 5];
const seq3 = [5, 7, 11, 13, 17];
const seq4 = [7, 11, 13, 17, 19, 23, 29];
const length = seq1.length * seq2.length * seq3.length * seq4.length;
const p = (seq, i) => seq[i % seq.length];
for (let i = 0; i < length; i++) {
console.log(p(seq1, i) * p(seq2, i) * p(seq3, i) * p(seq4, i));
}
@tail-call
Copy link
Author

tail-call commented Jul 12, 2020

Notice how computed length is wrong because 2 and 3 are shared between first two sequences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment