2
$\begingroup$

I'm realy sorry, if this question is a bit stupid... But this is my first time on mathematics stackexchange.

Do you guys now for example, how to know the number of monday in a year?

  • 0
    @F'OlaYinka: Your answer is perfectly fine apart from the easily fixed "$51$" typo.2012-11-13

3 Answers 3

1

There are 52 Mondays unless a) Jan 1 is a Monday or b) Jan 1 is a Sunday and the year is a leap year. In that case there are 53. Various algorithms for calculating day of week are available many places on the web. One page that has many formats is this one.

2

There are 365 days in a non-leap year. If you divide by 7 (the number of days in a week) you get

$\frac{365}{7} = 52 \frac{1}{7}$

which means that in a non-leap year, there are 52 full weeks, with one day left over. Therefore there will be one day that occurs 53 times, with the other days occuring 52 times.

The day that occurs 53 times will be the one on the first day of the year. For example, in 2011 the first day of the year was a Saturday, which means that there were 53 Saturdays in 2011, and 52 of every other day.

2012 is a leap year. That means that there are two days that appear 53 times (whichever days the 1st and 2nd January fall on). In 2012 the 1st Jan was a Sunday, and the 2nd Jan was a Monday. So in 2012, there will be 53 Sundays and Mondays, and 52 of every other day.

  • 1
    See also http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Purely_mathematical_methods for a formula to determine which day of the week January 1 is in a particular year.2012-11-13
2

This program computes days of the week for modern dates. You can step through the lines and attempt to glob together a compressed formula.

def isLeap(year):     if year % 4 != 0:         return False     if year % 400 == 0:         return True     if year % 100 == 0:         return False     return True     ## years divisible by 4, but not 100 are leap years, unliess     ##they are divisible by 400.  def dayOfWeek(day, month, year):     y = year - 1     total = y %7     total += (y//4 - y//100 + y//400)%7     total %= 7     daysInMonths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]     if isLeap(year):         daysInMonths[2] += 1     for k in range(month):         total +=daysInMonths[k]     total += day     total %= 7     dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]     return dayNames[total]  print (dayOfWeek(26, 5, 1957)) print (dayOfWeek(13,11,2012))