Not so long ago, I was given a job interview task. I was to write a function which deduces the day of the standard 7-day week of ANY calendar (even an imaginary one), provided I know how often leap years happen, if at all, how many months their year has, and how many days each month has. This is a fairly common introductory job-interview task, and in this article I'll be solving and explaining the math behind it.

His task was, given any kind of calendar definition (not necessarily the Gregorian), figure out what day of the week a certain month/day/year combination would fall on. He walks through the entire code to solve the problem, including a bit to output the resulting calendar to an HTML table for each month.

Link: http://www.sitepoint.com/php-job-interview-task-day-week-calculation]]>I don't know which is the most common way to calculate Pi in computer programs, but from the stochastics book a read for my recent stochastics exam, I have a randomized variation, which is quite cool I think.

The code example is included along with a bit of explanation for those not familiar with the concepts behind it. It uses two of PHP functions, pow() and mt_rand(), to run through a series of iterations and, using a preset precision value, find the "hits" to finally calculate the value at the end.

]]>