summaryrefslogtreecommitdiff
path: root/examples/gfcc/compiler/factorial.c
diff options
context:
space:
mode:
authoraarne <unknown>2004-09-28 19:44:02 +0000
committeraarne <unknown>2004-09-28 19:44:02 +0000
commit01f872bf5db46863565c44c7f40b337217d35e8e (patch)
tree6ea7ddb450efdd4e8da5aec6631da7b22b5911a9 /examples/gfcc/compiler/factorial.c
parent422b626a361c08b911471c04159931756887335c (diff)
gfcc report
Diffstat (limited to 'examples/gfcc/compiler/factorial.c')
-rw-r--r--examples/gfcc/compiler/factorial.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/examples/gfcc/compiler/factorial.c b/examples/gfcc/compiler/factorial.c
index 2a1c3f5f3..76fee32d0 100644
--- a/examples/gfcc/compiler/factorial.c
+++ b/examples/gfcc/compiler/factorial.c
@@ -10,11 +10,28 @@ int fact (int n) {
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)) ; n = n+1 ;
+ while (n < 11) {
+ printf("%d",fact(n)) ;
+ printf("%d",factr(n)) ;
+ n = n+1 ;
+ }
}
return ;
} ;