add factloop from course
This commit is contained in:
parent
a08024d982
commit
dc2122e5f8
1 changed files with 12 additions and 0 deletions
12
tests/33_fact-loop.test
Normal file
12
tests/33_fact-loop.test
Normal file
|
@ -0,0 +1,12 @@
|
|||
int factloop (int n) {
|
||||
int r = 1;
|
||||
while (n > 0) {
|
||||
r = n * r;
|
||||
n = n - 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void main () {
|
||||
puti(factloop(10));
|
||||
}
|
Reference in a new issue