Number theory

Table of contents

  1. Zeller's congruence

Zeller's congruence

begin
  global day_of_the_week
  w = ["Satur", "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri"]

  function day_of_the_week(year,month,day)
    J = year//100
    K = (year  if month in 3..12 else year-1)%100
    m = (month if month in 3..12 else month+12)
    n = (day + (m+1)*13//5 + K + K//4 + J//4 - 2*J)%7
    return w[n]+"day"
  end
end