Project Euler #19 in R
<p>I need help understanding why I am getting the wrong answer for Problem 19 of Project Euler.
The problem is: 
You are given the following information, but you may prefer to do some research for yourself.</p>

<blockquote>
  <p>1 Jan 1900 was a Monday.
  Thirty days has September,
  April, June and November.
  All the rest have thirty-one,
  Saving February alone,
  Which has twenty-eight, rain or shine.
  And on leap years, twenty-nine.
  A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
  How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?</p>
</blockquote>

<pre><code>#rm(list=ls())
days=seq(from=as.Date("1900/1/1"), to=as.Date("2000/12/31"), by="month")
firstSundays=days[weekdays(as.Date(days))=="Sunday"&amp;months(as.Date(days))=="January"]
length(firstSundays)
</code></pre>

<p>The answer it gives me is 14 and when I look at firstSundays it gives me:</p>

<pre><code>[1] "1905-01-01" "1911-01-01" "1922-01-01" "1928-01-01" "1933-01-01"
[6] "1939-01-01" "1950-01-01" "1956-01-01" "1961-01-01" "1967-01-01"
[11] "1978-01-01" "1984-01-01" "1989-01-01" "1995-01-01"
</code></pre>

<p>I don't understand what is going on here. Could someone please explain? I am fairly new to R and I'm not sure what I am doing wrong.</p>