3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php for ($i = 0; $i < 16; $i++) { var_dump(method($i) . "\t" . method1($i) . "\t" . pow(2, $i-1)); } function method($n) { if ($n <= 0) return 0; if ($n == 1) return 1; if ($n == 2) return 2; if ($n == 3) return 4; return method($n - 1) + method($n - 2) + method($n - 3); } function method1($n) { if ($n <= 0) return 0; $r = 1; for ($i = 0; $i < $n; $i++) { $r += method1($i); } return $r; }
based on lqjUA
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
string(7) "0 0 0.5" string(5) "1 1 1" string(5) "2 2 2" string(5) "4 4 4" string(5) "7 8 8" string(8) "13 16 16" string(8) "24 32 32" string(8) "44 64 64" string(10) "81 128 128" string(11) "149 256 256" string(11) "274 512 512" string(13) "504 1024 1024" string(13) "927 2048 2048" string(14) "1705 4096 4096" string(14) "3136 8192 8192" string(16) "5768 16384 16384"