[erlang-questions] Frying pan bug

Kenneth Lundin kenneth.lundin@REDACTED
Fri Mar 2 12:53:54 CET 2012


You don't handle negative input to fac/1 and you feed it with 4-11 -> -7

/Kenneth

On Fri, Mar 2, 2012 at 12:42 PM, Joe Armstrong <erlang@REDACTED> wrote:

> -module(bug).
> -compile(export_all).
>
> bug() -> p(0.3, 4, 11).
>
> c(N, M) ->  fac(M) div (fac(N)*fac(M-N)).
>
> fac(0) -> 1;
> fac(N) -> N*fac(N-1).
>
> p(P, M, N) -> 1.0 - math:pow(1-P, N-M)*c(N, M).
>
> Running bug:bug() tries to turn my machine into a frying pan
>
> Should this be renamed frying_pan.erl ?
>
> Anybody else see this?
>
>
> /Joe
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120302/7aeca1e8/attachment.htm>


More information about the erlang-questions mailing list