function mystery($y, $m, $d) {
$a = 0;
$b = 0;
$c = 0;
if($m < 3) {
$a = $m + 10;
$b = ($y-1) % 100;
$c = ($y-1) / 100;
}
else {
$a = $m - 2;
$b = $y % 100;
$c = $y / 100;
}
$w = (700 + (((26*$a)-2)/10)+$d+$b+$b/4+$c/4-(2*$c))%7;
echo $w;
}
One of my tutorial questions asks what the function calculates. I can go through and explain every calculation, but I'm sure that's not what we're expected to do. Is there any obvious use I'm not seeing?
It looks to me like it could be a checksum algorithm, because it always seems to generate a digit between 0 and 6.
ps, it was originally written in Java but I ported it to PHP for simplicity when I typed it into my computer to test. I can re-type the Java version in if anyone would prefer it.