Last active
September 26, 2018 16:25
-
-
Save belushkin/beb83b94f6e5b438e86f00ac46e53f98 to your computer and use it in GitHub Desktop.
Pascal's triangle in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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