How do I count thee? Let me count the ways?

Years having a month with exactly four weeks

      A year having a month with exactly four weeks will occur in 2026, 2037, 2043, 2054.       Such a year has February 1 on a S...

Monday, February 23, 2026

Years having a month with exactly four weeks

      A year having a month with exactly four weeks will occur in 2026, 2037, 2043, 2054.

      Such a year has February 1 on a Sunday, and is a non-Leap year so February has exactly 28 days.

      Here is the R code:

library(lubridate)

date_sequence <- seq(
  as.Date("2026-02-01"),
  as.Date("2056-02-01"),
  by = "years"
)

df <- data.frame(
  Feb_1 = date_sequence,
  day_of_week = weekdays(date_sequence), 
  is_leap = leap_year(date_sequence)
)

df <- subset(df, day_of_week == "Sunday" & is_leap == FALSE)

cat("The following years have a month (Feb) with exactly four weeks:", (year(df$Feb_1)))

# 2026, 2037, 2043, 2054 

End

No comments:

Post a Comment