source: git/Tst/Old/fak.tst @ 46976a6

spielwiese
Last change on this file since 46976a6 was 46976a6, checked in by Olaf Bachmann <obachman@…>, 26 years ago
* added status check to regress.cmd * added tst_status(1); call to each tst file, just before quit git-svn-id: file:///usr/local/Singular/svn/trunk@2271 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 775 bytes
Line 
1pagelength = 1000;
2proc sum
3{
4  if (#[1] <= 1) { return(#[1]); }
5  return (#[1] + sum(#[1] -1));
6}
7proc fak
8{
9  if (#[1] <= 1) { return(1); }
10  return (#[1] * fak(#[1] -1));
11}
12proc binom
13{
14  return (fak(#[1]) / (fak(#[1]-#[2]) * fak(#[2])));
15}
16"nesting too deep for fak(30)!!!!";fak(30);
17int i;
18int j;
19//for (i = 2; i<=10; i=i+1)
20//{
21//  i, "sum", sum(i), "fak", fak(i);
22//}
23//"binom(5,1)", binom(5,1);
24//$;
25string b;
26for (i=1; i<=16; i=i+1)
27{
28  b = "binoms " + string(i) + " ";
29  for (j=0; j<=i; j=j+1)
30  {
31    b = b + " " + string(binom(i,j));
32  }
33  b;
34}
35LIB "tst.lib";tst_status(1);$;
36"binom(5,0)", binom(5,0);
37"binom(5,1)", binom(5,1);
38"binom(5,2)", binom(5,2);
39"binom(5,3)", binom(5,3);
40"binom(5,4)", binom(5,4);
41"binom(5,5)", binom(5,5);
42LIB "tst.lib";tst_status(1);$;
Note: See TracBrowser for help on using the repository browser.