// TODO: find more triplets for different n sclass TripletLSFR { // params int n; int start = 0; int a, b, c; // the triplet // changing variables int step, value; // tap bit mask for different n's (2 through 24) static final int[] tapTable = { 0x3, 0x3, 0x3, 0x5, 0x3, 0x3, 0x2d, 0x11, 0x9, 0x5, 0x107, 0x27, 0x1007, 0x3, 0x100b, 0x9, 0x81, 0x27, 0x9, 0x5, 0x3, 0x21, 0x87 }; *(int *n, int *a, int *b, int *c) { value = start; } int cycleLength() { ret 1 << n; } int next() { step = (step+1) & ((1 << n)-1); int x = value; x ^= x >> a; x ^= x >> b; x ^= x >> c; ret value = x; } }