local fmt = require "fmt" local dates = {} local years = {} for y = 1900, 2100 do local has_five = false for m = 1, 12 do local fri = 0 local sat = 0 local sun = 0 for d = 1, fmt.month(m, y) do local t = os.time({year = y, month = m, day = d}) local dow = tonumber(os.date("%u", t)) if dow == 5 then fri += 1 elseif dow == 6 then sat += 1 elseif dow == 7 then sun += 1 end end local fd = os.date("%b - %Y", os.time({year = y, month = m, day = 1})) if fri == 5 and sat == 5 and sun == 5 then dates:insert(fd) has_five = true end end if !has_five then years:insert(y) end end print("Between 1900 and 2100:-") print($" There are {#dates} months that have five full weekends.") print(" The first 5 are:") for i = 1, 5 do print($" {dates[i]}") end print(" and the last 5 are:") for i = -4, 0 do print($" {dates[#dates + i]}") end print($"\n There are {#years} years that do not have at least one five-weekend month, namely:") fmt.tprint(" %d", years, 10)