Quoto

Learn / Library / Brainteasers

Calendar of a distant planet

BrainteasersHard

On the planet Kest the week has days, numbered to . A year has months of , , and days in that order. A year divisible by but not by is long: its last month has days instead of . Day of month of year is weekday , and the weekday number goes up by (back to after ) with every day, continuing across month and year boundaries. In years to , how many months begin on weekday ?

Checking an answer needs JavaScript. The hint and the solution open without it.

A whole number, a decimal, a fraction like 3/8 or a percent.

Hint

Work out the weekdays of the month starts in a year as offsets from the weekday of its first day, and see how the year start moves from year to year.

Solution
  1. In any year starting on weekday , the month starts are , , and , which are , , and modulo , so a year contributes months starting on weekday if is or , and none otherwise.
  2. An ordinary year has days, a multiple of , so the next year starts on the same weekday; a long year has days and shifts the start by .
  3. The long years up to are the multiples of other than , , , and , so the start weekday of year is the number of long years before , modulo .
  4. This puts the start on weekday in years to , to and to ( years), and on weekday in years to , to and to ( years).
  5. These years contribute months each, so the total is .

Answer: