source:
PSPA/madxPSPA/src/mad_math.c
@
477
Last change on this file since 477 was 430, checked in by , 11 years ago | |
---|---|
File size: 333 bytes |
Line | |
---|---|
1 | #include "mad_math.h" |
2 | |
3 | double |
4 | fact(int i) |
5 | { |
6 | int k; |
7 | double nfact; |
8 | |
9 | if(i == 0) { |
10 | return(1.0); |
11 | } else if(i == 1) { |
12 | return(1.0); |
13 | } else if(i > 1) { |
14 | nfact = 1.; |
15 | for (k=1;k<=i;k++) { |
16 | nfact = nfact*k; |
17 | } |
18 | return(nfact); |
19 | } else if(i < 0){ |
20 | return(-1.0); |
21 | } else { |
22 | return(-1.0); |
23 | } |
24 | } |
25 | |
26 |
Note: See TracBrowser
for help on using the repository browser.