-->
当前位置:首页 > 题库

PROGRAMMING:C programming experiment 4-1 factorial values of all numbers from 1 to n

Luz5年前 (2021-05-10)题库391
Known factorial function is as follows, using this function, program to calculate and output the factorial value of all numbers from 1 to n.
Where n is entered by the user from the keyboard.
```
unsigned long Fact(unsigned int n)
{
unsigned int i;
unsigned long result = 1;
for (i=2; i<=n; i++)
result *= i;
return result;
}
```
###Input format:
The user enters a positive integer n from the keyboard.
###Output format:
Displays the factorial values of all numbers from 1 to N line by line.
###Input example:
Here is a set of inputs. For example:
```in
five
```
###Output example:
The corresponding output is given here. For example:
```out
1! = one
2! = two
3! = six
4! = twenty-four
5! = one hundred and twenty
```







answer:If there is no answer, please comment