Skip to content

Instantly share code, notes, and snippets.

@JossWhittle
Created August 10, 2012 00:26
Show Gist options
  • Save JossWhittle/3309497 to your computer and use it in GitHub Desktop.
Save JossWhittle/3309497 to your computer and use it in GitHub Desktop.
pascal :: Double -> Double -> Double
pascal r 0 = 1
pascal r c = (pascal r (c - 1)) * (((r + 1) - c) / c)
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