From e4748e998453b979af46983a079f2ec3d307ada4 Mon Sep 17 00:00:00 2001 From: aarne Date: Tue, 2 Mar 2010 19:10:56 +0000 Subject: restored gfcc example (GF C compiler) --- examples/gfcc/factorial.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 examples/gfcc/factorial.c (limited to 'examples/gfcc/factorial.c') diff --git a/examples/gfcc/factorial.c b/examples/gfcc/factorial.c new file mode 100644 index 000000000..76fee32d0 --- /dev/null +++ b/examples/gfcc/factorial.c @@ -0,0 +1,38 @@ +int fact (int n) { + int f ; + f = 1 ; + { + while (1 < n) { + f = n * f ; + n = n - 1 ; + } + } + return f ; +} ; + +int factr (int n) { + int f ; + { + if (n < 2) { + f = 1 ; + } + else { + f = n * factr (n-1) ; + } + } + return f ; +} ; + +int main () { + int n ; + n = 1 ; + { + while (n < 11) { + printf("%d",fact(n)) ; + printf("%d",factr(n)) ; + n = n+1 ; + } + } + return ; +} ; + -- cgit v1.2.3