Strange, we don't get the same number as Trice ... you & I : 18,528,584,051,601,166,000 Trice : 18,528,584,051,601,162,496
There's something strange in googledocs: look at the value of the product for the line with m=3 ... it ends in 808 ... MaX. 2010/5/28 Øystein Johansen <oyst...@gnubg.org>: > ??? Strange. I copied and pasted from a web site. > > function productRange(a,b) { > var product=a,i=a; > > while (i++<b) { > product*=i; > } > return product; > } > > function combinations(n,k) { > if (n==k) { > return 1; > } else { > k=Math.max(k,n-k); > return productRange(k+1,n)/productRange(1,n-k); > } > } > > function distributions(N, M) { > return combinations( N+M-1,M); > } > > Maybe I should not trust everything I read. However, I can't immediately see > any bugs in the above code.... > Aha! Now I see! It's wrong when k = 0, I'll fix it. Hang on. > > May be a bad fix, but I think it works better now. > > -Øystein > > > 2010/5/28 Massimiliano Maini <maxma...@gmail.com> >> >> Now it works. >> >> Your combinations function seems to be wrong for m=0: >> >> combin(24,0) = 1 >> combinations(24,0) = 25 >> >> Guess you just have to define distribution as a function of COMBIN ... >> >> MaX. >> >> 2010/5/28 Øystein Johansen <oyst...@gnubg.org>: >> > 2010/5/28 Massimiliano Maini <maxma...@gmail.com> >> >> >> >> Google docs, right .. excel is so has been :) >> >> >> >> BTW, your link does not work. >> > >> > I see .... I'll try to publish it as a web page: >> > >> > >> > http://spreadsheets.google.com/pub?key=tqUcK-zFdgQC_byUJvbgqvQ&output=html >> > >> > -Øystein >> > >> > > > _______________________________________________ Bug-gnubg mailing list Bug-gnubg@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnubg