Skip to content

Instantly share code, notes, and snippets.

@belushkin
Last active September 26, 2018 16:25
Show Gist options
  • Save belushkin/beb83b94f6e5b438e86f00ac46e53f98 to your computer and use it in GitHub Desktop.
Save belushkin/beb83b94f6e5b438e86f00ac46e53f98 to your computer and use it in GitHub Desktop.
Pascal's triangle in PHP
function pascal_triangle($c, $r)
{
if ($c == 0 || $c == $r) {
return 1;
} else {
return pascal_triangle($c-1, $r-1) + pascal_triangle($c, $r - 1);
}
}
echo pascal_triangle(1,3), "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment