source: git/Tst/Old/binomial.tst

spielwiese
Last change on this file was 4173c7, checked in by Hans Schoenemann <hannes@…>, 13 years ago
use div instead of /, part 1 git-svn-id: file:///usr/local/Singular/svn/trunk@14191 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 510 bytes
Line 
1proc fak2
2{
3  if (#[1] <= #[2]) { return(#[2]); }
4  return (#[1] * fak2(#[1] -1,#[2]));
5}
6
7proc fak
8{
9  return (fak2(#[1],1));
10}
11
12proc binom
13{
14  if (#[2] == 0) { return(1); }
15  return ( fak2(#[1],#[1]-#[2]+1) div fak(#[2]) );
16}
17// -------------------------------------------------------
18
19int i;
20int j;
21string b;
22for (i=1; i<=5; i=i+1)
23{
24  b = "binomial coefficients " + string(i) + " ";
25  for (j=0; j<=i; j=j+1)
26  {
27    b = b + " " + string(binom(i,j));
28  }
29  b;
30}
31listvar(all);
32LIB "tst.lib";tst_status(1);$;
Note: See TracBrowser for help on using the repository browser.