### Spooky Question...

greenspun.com : LUSENET : Lexington High School Mathematics : One Thread

At Mr. Kelly's request, here's a problem... As I post this message, it is Friday the 13th. Furthermore, tonight there will be a full moon. To top off everything, it is Halloween month. Apparently a rare event. But how rare? On average once in how many years does it happen? I'm not sure either. Post your responses.

-- RCM (matei1@banet.net), October 13, 2000

152 372 524 744 1116 2175 2395 2547 2767 2919 3139 3386 3511 3606 3758 3978 4130 4350 4445 4597

Add 2000 to all of those years and you have the next 20 times this will occur (the years).

The average of the differences is 229.85. There are two modes of the differences, 220 and 152. They both occur 7 times. One of the differences is 372 (sum of 220 and 152), and could have occurred due to a problem with my program.

I solved this with a program which was as follows.

//Phil Morse-Fortier //Spooky Question (from math forums) #include #include "apstring.h" #include #include

int run=0; int year=0; int month=10; int day=13; int tempmoonday; double moonperiod=29.5305882; double tempmoonperiod=moonperiod; int moondate=1; bool datecheck(long year, int mon, int d); void moondatecheck(int moonday);

void main() { while (run<20) { day = day + 7; moondate = moondate + 7; while ((!((month == 10) && (day == 13))) || (moondate != 1)) { day = day+7; moondate = moondate+7; moondatecheck(moondate); datecheck(year, month, day); } cout << year << endl << day << endl << month << endl; run++; } }

bool datecheck(long yr, int mon, int d) { if (mon == 4 || mon == 6 || mon == 9 || mon == 11) { if (d > 30) { month++; day = day-30; return 1; } else { return 1; } } else if(mon == 2) { if (yr/4 == yr/4.) { if (yr/100 == yr/100.) { if (year/400 == year/400.) { if (d > 29) { month++; day = day-29; } } else { if (d > 28) { month++; day = day-28; } } } else { if (d > 29) { month++; day = day-29; } } } else if (d > 28) { month++; day = day-28; } } else { if (d > 31) { month++; day = day - 31; } if (month == 13) { month = 1; year++; } } return 1; }

void moondatecheck(int moonday) { tempmoonday= moonday; if (moonday >= tempmoonperiod) { moondate = moondate - int(tempmoonperiod); tempmoonperiod = tempmoonperiod + moonperiod - tempmoonday + moondate; } } There ya go... I h

-- Student Phil M-F (lepernthern@hotmail.com), October 30, 2000.

Ok, just to show the limit.... occurences average 1 152 10 291.9 100 214.54 1000 211.33 10000 211.009 100000 210.939 250000 210.93 500000 210.933

The predicted limit value was 206.714 (29.5305882*7). (Testing of 1m is being done)

-- Student Phil M-F (lepernthern@hotmail.com), October 31, 2000.