title: understanding the fizz buzz in C#
body: <p>When solving "fizz-buzz" in C# using a "while" loop, I found out that first I should find the multiples of both 3 and 5 (multiples of 15) and then go to the multiples of 3 and 5 like below.  </p>
  
  <pre><code>int myval = 0;
  
  while (myval &lt; 100)
  {
      myval = myval + 1;
  
      if (myval % 15 == 0)
      {
          listBox1.Items.Add("fizzbuzz");
      }
      else if (myval % 3 == 0)
      {
          listBox1.Items.Add("fizz");
      }
      else if (myval % 5 == 0)
      {
          listBox1.Items.Add("buzz");
      }
      else
      {
          listBox1.Items.Add(myval);
      }
  }
  </code></pre>
  
  <p>But if I write the code to filter multiples of 3 and 5 first and then go to the multiples of both 3 and 5 (multiples of 15) like below the end result only shows the fizz (multiples of 3) and buzz (multiples of 5) without fizz-buzz (multiples of both 3 and 5). Does anyone know what's the reason for this even IDE doesn't show me any errors.</p>
  
  <pre><code>myval = 0;
  
  while (myval &lt; 100)
  {
      myval = myval + 1;
  
      if (myval % 3 == 0)
      {
          listBox1.Items.Add("fizz");
      }
      else if (myval % 5 == 0)
      {
          listBox1.Items.Add("buzz");
      }
      else if (myval % 15 == 0)
      {
          listBox1.Items.Add("fizzbuzz"); // for multiples of both 3 and 5  
      }
      else
      {
          listBox1.Items.Add(myval);
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ucpPM.jpg" alt="end result without fizz-buzz multiples of both 3 and 5"></p>