Skip to content

Instantly share code, notes, and snippets.

@rmehner
Created July 6, 2010 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmehner/465148 to your computer and use it in GitHub Desktop.
Save rmehner/465148 to your computer and use it in GitHub Desktop.
<?php
class NumberCruncher {
public function __call($m, $n) {
switch($m = substr($m, -1, 1)) {
default: return ($m == 'F') ? (9 * $this->C($n[0])) : ($n[0] * ($n[0] * 0.5));
case 'A': return $n[0] + 4;
case 'B': return $n[0] * 3;
case 'D': return ($n[0] == 0) ? (1) : ($n[0] * $this->D($n[0] - 1));
case 'E': return ($n[0] > 1) ? ($this->E($n[0] - 1) + $this->E($n[0] - 2)) : ($n[0]);
case 'G': return $this->D($n[0]) - $this->E($n[0]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment