title: Double Elimination Tournament Algorithm for byes %4
body: <p>I'm trying to code a Double Elimination tournament where the brackets are based on mod 4.  The first round should handle all of the byes so that after round 2 there will be no more byes.  I'm having a hard time trying to figure out the actual math behind determining the amount of byes I need.  If anyone can help me with the math behind this it would be greatly appreciated.</p>
  
  <p>There are 4 possible answers for anything mod 4 (0,1,2,3) I need to handle byes for 1,2,3.</p>
  
  <p>An example of what I mean is
  13 players so (13%4=1)
  so the round 1 bracket should look like
  1vs2
  2vs3
  3vs4
  4vs5
  5vs6</p>
  
  <p>and round 2 is
  7vs winner
  8vs winner
  9vs winner
  winner vs winner  and then you have the losers bracket</p>
  
  <p>Basically if your familiar with the website Challenge,  I want to generate my brackets similar to them, but I can't figure out the math behind their determining of the byes.</p>
  
  <p>If anybody has done something similar to this I would greatly appreciate his help.</p>