From: Michael Beck Date: Wed, 30 Jul 2008 00:38:46 +0000 (+0000) Subject: the famous Factorial example X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=558c2a2d05d32622da09ce56021935e733fa287a;p=libfirm the famous Factorial example [r20776] --- diff --git a/ir/be/test/fak.c b/ir/be/test/fak.c new file mode 100644 index 000000000..5f971e412 --- /dev/null +++ b/ir/be/test/fak.c @@ -0,0 +1,14 @@ +#include +#include + +int factorial(int x) { + if (x == 0) + return 1; + + return x * factorial(x-1); +} + +int main(int argc, char **argv) { + int val = atoi(argv[0]); + printf("%d\n", factorial(val)); +}