One (last?) trick to reduce the number of iterations.

I changed this:
    
    
      var residues: seq[int] = @[]
      var pc = 1
      while pc < modpg: (pc += 2; if gcd(modpg, pc) == 1: residues.add(pc))
      let rescnt = residues.len
    
    

to this:
    
    
      var residues: seq[int] = @[]
      var pc = 1
      var inc = 4
      while pc < modpg: (pc += inc; inc = inc xor 0b110; if gcd(modpg, pc) == 
1: residues.add(pc))
      let rescnt = residues.len
    

This reduces the number of times `gcd` is called from half the numbers (all the 
odds) upto modpg (modpg/2) to a third (modpg/3).

This change produces the P3 PG residue sequence: `pcs = 6m +|- 1`
    
    
      pc = 1, 5, 7, 11, 13, 17, 19...
            +4 +2  +4  +2  +4  +2
    

So while it shaves off some iterations of `gcd` it's still not enough to get 
P17 to compile.

`A REQUEST:` It would be really, really nice to use the boolean operators like: 
`x ^= y; x &= y`; etc. 

Reply via email to