aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/04-fact.c
blob: 0982e08348c08595ffe2aca0a4e48510cc2eecfb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* EXPECT:
6! = 720
*/

int
fact(int x)
{
   int y = 1;
   while (x >= 1) {
      y *= x;
      x -= 1;
   }
   return y;
}

extern int printf();
int main() { printf("6! = %d\n", fact(6)); }