mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
39 lines
408 B
C
39 lines
408 B
C
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 ;
|
|
} ;
|
|
|