« Mac OS X Security Update 2009-001 可能會破壞你的 Perl (CPAN) | Home | REPL in Perl »

March 13, 2009

算算一年中有幾個十三號星期五

2009 年由於二月、三月都是 13 號星期五,所以還搞了部電影出來。不過讓我比較好奇的是:一年之中最多會有幾個十三號星期五?

大致上翻了一下月曆發現好像都不會超過三個。於是寫了個程式來測試一下:

輸出大約是這樣

1 black Friday in the year 2000: 2000-10-13
2 black Fridays in the year 2001: 2001-4-13 2001-7-13
2 black Fridays in the year 2002: 2002-9-13 2002-12-13
1 black Friday in the year 2003: 2003-6-13
2 black Fridays in the year 2004: 2004-2-13 2004-8-13
1 black Friday in the year 2005: 2005-5-13
2 black Fridays in the year 2006: 2006-1-13 2006-10-13
2 black Fridays in the year 2007: 2007-4-13 2007-7-13
1 black Friday in the year 2008: 2008-6-13
3 black Fridays in the year 2009: 2009-2-13 2009-3-13 2009-11-13
1 black Friday in the year 2010: 2010-8-13
1 black Friday in the year 2011: 2011-5-13
3 black Fridays in the year 2012: 2012-1-13 2012-4-13 2012-7-13
2 black Fridays in the year 2013: 2013-9-13 2013-12-13
1 black Friday in the year 2014: 2014-6-13
3 black Fridays in the year 2015: 2015-2-13 2015-3-13 2015-11-13
1 black Friday in the year 2016: 2016-5-13
2 black Fridays in the year 2017: 2017-1-13 2017-10-13
2 black Fridays in the year 2018: 2018-4-13 2018-7-13
2 black Fridays in the year 2019: 2019-9-13 2019-12-13
2 black Fridays in the year 2020: 2020-3-13 2020-11-13
1 black Friday in the year 2021: 2021-8-13
1 black Friday in the year 2022: 2022-5-13
.... (略)

跑完這個程式發現未來一萬年之中都不會有超過三個黑色星期五的年份。似乎三個就是上限了。這感覺起來是個不錯的數學證明題目。

而其中有三個黑色星期五的年份,佔了約整體的七分之一。換句話說每七年中就有一年會是三個星色星期五。但從 2009 年開始算的話,未來七年當中的 2012 跟 2015 也都是有三個黑色星期五的年份。比例還真是高。

另一個有趣的事實則是:每年都至少會有一個十三號星期五。

No TrackBacks

TrackBack URL: http://chupei.pm.org/mt/mt-tb.cgi/539

Leave a comment

Pages

OpenID accepted here Learn more about OpenID

About this Entry

This page contains a single entry by gugod published on March 13, 2009 1:12 AM.

Mac OS X Security Update 2009-001 可能會破壞你的 Perl (CPAN) was the previous entry in this blog.

REPL in Perl is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.