Quizzes & Puzzles25 mins ago
How can I work out the day someone was born?
Answers
No best answer has yet been selected by Impret-Sir. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.I wrote a program to work this out and used this formula
N = d + 2m + [3(m+1)/5] + y + [y/4] - [y/100] + [y/400] + 2
where d is the day of the month, m is the number of the
month, and y is the year. The brackets around the divisions mean to
drop the remainder and just use the integer part that you get.
a = (14 - month) \ 12
Y = year - a
m = month + 12 * a - 2
d = (day + Y + Y \ 4 - Y \ 100 + Y \ 400 + (31 * m) \ 12) Mod 7
Where \ means integer divison, i.e., dismiss any decimal digits after the decimal point.
and MOD takes the remainder of a division, i.e. 5 MOD 3 = 2, it divides once and the remainder is 2.
So taking today as an example,
a = (14 - 11) \ 12 = 0
y = 2004 - 0 = 2004
m = 11 + 12 * 0 - 2 = 9
d = [10 + 2004 + (2004\4) - (2004\100) + (2004\400) + ((31 * 9)\12)] MOD 7
gives:
(2014 + 501 - 20 + 5 + 23)MOD 7
gives:
2523 MOD 7
which is 3, if you count sunday as 0, Monday as 1, etc, then 3 is Wednesday.
Works every time, if the year is greater than 1582 (start of Julian calender.
Tweed, I can't quite get the month bit.
you said:
m = month + 12 * a - 2
m = 11 + 12 * 0 - 2 = 9
That's 11+12 = 23 then 23*0 = 0 then 0-2= -2, not 9.
Anything multiplied by zero will always be zero.
Ignoring this and treating the addition and subtraction first then doing the multiplication would give 11+12 = 23 then multiply by (0 - 2) would give 23 * -2 = -46
Still not 9. I am at a loss.
There is a system called Zeller's congruence (look it up in Google) that works for any date, even before Julian/Gregorian change and catering for the 11 lost days.
I also remember something called "The Golden Formula" on the back of old school exercise books that was meant to work this out, but I can't remember waht it was.
Whenever I want to work out a thing like that, I work out the day of the date concerned in this year (by counting the days and months from now) and then correcting for the number of years and leap years.
e.g. 26th November 1982
26th November 2004 is in 15 days time, therefore it will be a Friday.
1982 is 22 years before 2004, therefore subtract 22 days from Friday (makes Thursday).
between 1982 and 2004 there were 6 leap years, so subtract another 6 (makes Friday).
(22 + 6 = 28; 28 days before Friday was a Friday)
Therefore 26/11/82 was a Friday.
Related Questions
Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.