Created
August 10, 2012 00:26
-
-
Save JossWhittle/3309497 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pascal :: Double -> Double -> Double | |
pascal r 0 = 1 | |
pascal r c = (pascal r (c - 1)) * (((r + 1) - c) / c) |
This file contains hidden or 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
public void p15() { | |
System.out.println(pascal(40d, 20d)); | |
} | |
public Double pascal(Double r, Double c) { | |
if (c == 0) { | |
return 1d; | |
} | |
return pascal(r, c - 1) * (((r + 1) - c) / c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment