贴个C语言版本的阶乘函数,以响应群众呼声。
- /* 阶乘 */
- DD1 (fact) {
- int i;
- int from = (int) N(in_1);
- if(from < 0) {
- ec_ex_syntax ("factorials for negative integers");
- RETURN_FAILURE;
- }
- NW(out) = 1;
- for(i = 1; i <= from; i ++) {
- NW(out) *= (ec_value_t) i;
- }
- } END_OF (out)
复制代码 |
|