Calculating the number of days between two arbitrary dates is doable for humans and trivial on modern computers. However, calculating the number of working days: Mondays through Fridays, is more complicated. In this puzzle you are asked to devise an algorithm for doing this. It is something you can do on the back of a napkin, so you don’t need anything besides pen, paper and the rational part of your brain.

#### Problem

Given two dates where , what is the number of workdays between these two dates? Assume that only Saturdays and Sundays are not workdays: holidays can be ignored.

You may use the following definitions augmented with any standard mathematical functions, like and .

- is a date
- Subscripts are used to indicate different dates:
- yields the number of days between two dates. This is negative if and zero if the dates are identical
- gives the day of the week for the given date as a number (1 = Monday, 2 = Tuesday, …, 7 = Sunday)
- gives the number of the week for the specified date (in the range 1 up to including 53)
- is the set of numbers that represent working days (a subset of the domain of the weekday function)

Try to work out a solution first, then expand mine below.