I'm looping over all length i bitstrings and was wondering how to tell if it is a repetition of a previous bitstring? Basically I want to skip 11, 1010, 1111, 0101, 101101 etc but not 1011, 1100, 1000, 101001 etc
These bit-strings are the periods of binary numbers so if they repeat it generates the same number which will throw off my data processing program.
The repeating sequences need to be adjacent and cover all of j without overflow
skip = false; for(int i = 1; i<=n/2 && !skip; i++){ if(n%i == 0){ skip = true; for(int k=1; k<=n/i; k++) { if(((j&(j >> (i*k)))&((1<<i) - 1)) != (j&((1<<i) - 1))){ skip = false; break; } } } } if(skip) continue; This is my current attempt but it seems to fail to detect any.
n is the length of the bit-string in bits
j is the bit-string
EDIT: Fixed a few typing errors, but now it detects 10 but not 11
skip == true;does nothing. Theif(skip) continue;outside of the loop does nothing and you pulled the variablejout of seemingly nowhere. We need a bit more information here about what you're trying to do and whatjandiare.