title: Mistake in my code and lucky answer
body: <p>Spoiler alert!! for project euler problem 19.</p>
  
  <p>The problem is how many sundays fall on the first of the month from 1901 to 2000. Given information: Jan 1st 1900 was a monday, Jan &amp; march etc have 31 days, April, June etc 30 days and a leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. which in this case applies to year 2000. </p>
  
  <p>I got the correct answer, but when I checked my results with a real calendar, it turns out my code is counting saturdays. I don't see why it is doing that, can someone help?!</p>
  
  <pre><code>public class Sunday {
  
  public static void main(String[] args) {
  
      int sundayCount = 0;
      int currentday = 0; // monday is 0, sunday will be 6
      int dayLimit = 0;
  
      for (int year = 1900; year &lt; 2001; year++) {
          for (int month = 1; month &lt; 13; month++) {
              // 30 days April, June, September, November
              if (month == 4 || month == 6 || month == 9 || month == 11)
                  dayLimit = 30;
  
              // leap year
              else if (month == 2 &amp;&amp; year % 4 == 0)
                  dayLimit = 29;
  
              // February not leap year
              else if (month == 2 &amp;&amp; year % 4 != 0)
                  dayLimit = 28;
  
              // Jan, March, May, July, August, October, December
              else
                  dayLimit = 31;
              for (int day = 1; day &lt;= dayLimit; day++) {
                  if (day == 1 &amp;&amp; currentday == 6 &amp;&amp; year &gt; 1900) {
                      System.out.println("year: " + year);
                      System.out.println("month: " + month);
                      sundayCount++;
                  }
                  if (currentday &lt; 6)
                      currentday++;
                  else
                      currentday = 0;
              }
          }
      }
      System.out.println(sundayCount);
  }
  }
  </code></pre>