1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

some more calculation

Discussion in 'The Lounge - Off Topic' started by Tinus1959, Oct 26, 2007.

Click here to banish ads and support Certforums by becoming a Premium Member
  1. Tinus1959

    Tinus1959 Gigabyte Poster

    This one has nothing to do with computers what so ever. It is just to show off on birthday partys.
    Did you ever wonder what day august the 16th was in 1959? (I guess the answer is no but I'm going to tell you anyhow) It was a Sunday.
    You can do this in your head. I'll show you.
    First the background. If januari the first is a Sunday, februari the first is always a Wednesday and march the first is a Wednesday (except for a leapyear, but I'll cover that later). If march the first is a Wednesday, april the first is a Saterday and so on. If we call Sunday 1, Monday 2, Tuesday 3 etc, we could write down a number that describes the complete year. This number is 144 025 036 146. This is easy to remember as 12^2, 5^2, 6^2, 12^2+2.
    So when we know the day for januari the first we know the whole year!
    How to calculate the 'yearnumber'.
    Take the year - 1900 and devide by 12. The outcome = a, the remainder = b.
    Take the remainder b and devide by 4. The outcome is c.
    Add a,b and c together and you basicly have your yearnumber.
    Add to this yearnumber the month offset and last add the daynumber. Do a mod 7 on this. The remainder is your weekday in where Sunday is 1.

    august 16 1959.
    year 59.
    59 / 12 = 4 (a) remainder = 11 (b)
    11 / 4 = 2 (c).
    Yearnumber = 4+11+2=17.
    August is the 8th month which gives us a 3 (from 144025036146)
    The day was 16, so the total is 17 + 3 + 16 = 36.
    36 mod 7 = 1 and 1 was a Sunday.

    This trick works for 1901 up to 2099.
    Let's check a second example: oktober 26 2007.
    2007 -1900 = 107.
    107 / 12 = 8 rem 11
    11 / 4 = 2
    Oktober gives a 1
    Day = 26
    Adding all up gives 8+11+2+1+26=48
    48 mod 7 = 6 which is a Friday.
    Heyyyy, today it is Friday: almost weekend:biggrin.

    Does this always work? No, not quite. The only wrongs are the months Januari and Februari during leapyears (except for februari 29, that is in fact correctly calculated). For these two months you calculate the day of tomorrow. So if the outcome would be Wednesday it must be corrected to Tuesday.

    Have fun!
    Certifications: See my signature
  2. newkoba

    newkoba Byte Poster

    get help you sick bored mathematician :biggrin
    Certifications: Security + and CEH
    WIP: CWNA and CWSP
  3. Tinus1959

    Tinus1959 Gigabyte Poster

    Well, in fact I'm a bio-chemical engineer now working in IT for allmost 20 years as trainer.
    Certifications: See my signature

Share This Page