summaryrefslogtreecommitdiff
path: root/examples/gfcc/compiler/factorial.c
blob: 76fee32d027f0462c0846520e2f1718dd0beea4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 ;
} ;