aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/04-fact.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/04-fact.c')
-rw-r--r--test/04-fact.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/04-fact.c b/test/04-fact.c
new file mode 100644
index 0000000..0982e08
--- /dev/null
+++ b/test/04-fact.c
@@ -0,0 +1,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)); }