Amazing Calendar Trick
This trick was performed on Indian
TV by the Mathematical wizard
Shakuntala Devi long time back .
The trick is as follows :
A member of the audience asks the calendar date on which
e.g third Wednesday falls in July 2011 and she readily tells
that it is 20° of July. This can be done for any weekday of
any month of any year.How to do the trick
| deduced the following formula by trial and error .
This formula worked for all the cases | tried in different
centuries . Some of the steps are similar to those used
for calculating weekday from date .
Date = (n-1) *7+
(weekdaycode — monthcode — Yearcode) mod 7
Where n is the the week number .Example.
Date = (0-1) 47+
(weekdaycode - monthcode~ Yearcode) mod 7
Where nis the the week number
For example , or third Wednesday of luly 2013,
N=3 (Third Wednesday)
Weekdsycode = 3 for Wednesday
Monthcode = 6 for iuly
Yeatcode = Stor 2011
Date=2"7 + (3-6-S) mod?
218 4(-8)mod 7
1446 =20
Ifthe date value is larger than the number of days in that month, it means that the
‘questioner did not check the calendar before asking question
“The nest few slides show the tables required and complete examplesweekdaycode Table.
Sunday : 0
Monday : 1
Tuesday :2
Wednesday :3
Thursday : 4
Friday :5
Saturday : 6Monthcode Table
January : 0
February :3
March: 3
April: 6
May:
June :4
July 6
August :2
September : 5
October :0
November : 3
December : 5Formula for Yearcode
yearcod.
(centurycode + [last two digits of year] + (last two digits of year] div 4)) mod 7
+ ‘Div’ is the operator for integer division. Just lke ‘mod’ gets the remainder of a
division, ‘div’ gets its integer quotient. For example, 17 div 7 = 2 (with a remainder
of 3) and 17 mod 7 = 3
+ The century code follows a recurrent pattern, and can be used for any
date in the Gregorian calendar:
+ 1600s:6
+ 1700s:4
+ 1800s: 2
+ 1900s:
+ 2000s: 6; repeating the pattern
+ 2100s: 4; 6-4-2-0 pattern goes on...Example of Yearcode calculation
yearcode =
(centurycode + [last two digits of year] + ([Iast two digits of year]
div 4)) mod 7
‘A Fornon-leap year:e.g 2011
6 +11 + 11.div4) mod 7 = (641142) mod 7
8 For leap year : ¢.g 1956
Yearcode = (0+ 56+ 56 div4) mod 7 = (56+14) mod 7 =0
This yearcode is used for the months from March to December and yearcode -
‘Lis used for January and February. Whenever you get a negative value for
yearcode add 7 to get the correct yearcode.
e.g we get -1 in this case and add 7 to get 6 which is to be used as year code
for January and FebruaryModular arithmetic
* Calculation of
Date = (n-1) *7+
(weekdaycode ~ monthcode - Yearcode) mod 7
Where n is the the week number
Case (i) : When the value of expression within parenthesis
is positive , the value is the remainder obtained after
dividing it by 7 e.g if the value of the expression is 10 the result will
be 3.
Case (ii) : When the value of the expression is negative , ignore the
sign and divide by 7 and get the remainder . Subtract this value
from 7 to get the actual result . e.g if the value of the expression is
-12,, divide 12 by 7 to get remainder of 5 . Subtract 5 from 7 to get
actual result.Complete example for Non-leap Year
Suppose we are asked to find 4" Friday of March 2011
Yearcode for 2011=5
Monthcode for March = 3
Weekdaycode for Friday = 5
N=4( 4" Friday )
Date =(n-1) *7+
(weekdaycode — monthcode — Yearcode) mod 7
Where n is the the week number
Date =(4-1)* 7 + ( 5-3-5) mod 7 = 21+ (-3) mod 7
=214+4=25Complete Example for Leap Year
Suppose we are asked to find date corresponding to the 2"
Sunday of February 2012.
Yearcode for 2012 ( Leap Year ): 6 for January and February
and 0 for the remaining months .
Monthcode = 3 for February
Weekdaycode = 0 for Sunday
N= 2 (second Sunday)
Date = (n-1) *7+
(weekdaycode - monthcode — Yearcode) mod 7
Where n is the the week number
Date = (2-1) *7+(0-3-6) mod 7=7 +(-9) mod 7 = 745
=12