Is this a good Pseudo-Random Number Generator? I discovered what appears to be a good quality pseudorandom number generator, but I have not subjected it to any statistical tests beyond bit frequency, bit pair frequency, and least-significant bit frequency tests. It generates a block of bytes by evolving deterministically, starting with a seed state. I'm new to Stack Exchange, so please bear with me.
Here is the process (test example):
start with a 32-byte sequence (256 bits) and an integer variable k, and for each byte X(i),

$s = 7 - (X[i+1]+X[i+2]) \bmod 15$
$X[i] = ((X[i] + k) * 2^s) \bmod 255$
$k = k + X(i)$

and I implemented this process in C as follows:
    #define CYCLES 1 // full cycles per byte of the seed size per evolution
    unsigned int i, j;  
    unsigned char a, k;  
    int s;  
    for (i = 0; i &lt; 32*CYCLES; i++) {  
        a = X[i%32]+k;  
        s = 7-(X[(i+1)%32]+X[(i+2)%32])%15;  
        for (j = 0; j &lt; abs(s); j++) {  
            if (s&lt;0) {  
                a = ((a&amp;1)==1)?((a&gt;&gt;1)+128):(a&gt;&gt;1);  
            }  
            else {  
                a = ((a&amp;128)==128)?((a&lt;&lt;1)+1):(a&lt;&lt;1);  
            }  
        }  
        X[i%32] = a;  
        k += a;  
    }  

The C implementation of modular multiplication by powers of uses bitwise operations and differs in only one way from an algebraic method: when a = 255, the output is always 255. This is essentially a rotation of the byte abs(s) times to the left when the sign is positive, and the right when it is negative.
If I initialize the array X with a seed value such as &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ012345&quot; and evolve it 32 times, then map out the resulting bits or do basic tests for randomness, it appears to be very similar to true randomness. Am I missing something, or is this a good PRN generator?
What could possibly be an advantage of your method from directly sampling the bytes from the prime number distribution?
Like:
Start at some integer $k$ and sample the 8 bits as: $k*30+\lbrace -13,-11,-7,-1,1,7,11,13\rbrace$, each time when it is a prime number, you set the bit at that position to 1, otherwise to 0. If your sampled Byte is $&lt;= 64$ use k-= Byte, otherwise use k+= Byte for the next sample.
Isn't this much simpler than your method, or am I missing something of importance?