File: fac.ft

package info (click to toggle)
fudgit 2.42-6
  • links: PTS
  • area: non-free
  • in suites: potato, woody
  • size: 2,468 kB
  • ctags: 2,375
  • sloc: ansic: 27,729; makefile: 793; yacc: 724; lex: 102; asm: 29; fortran: 15
file content (20 lines) | stat: -rw-r--r-- 370 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Print factorial of numbers from 0 to 120.
# Some variable scope explanation are given too.
free @all

cmode
	func fac(x) {  # This `x' is a prototype: it does not exist.
		if (x <= 0)  {
		   return(1)
		} else {
		   return(x * fac(--x))
		}
	}
    {
   		auto x=1  # This `x' is a local scalar variable
   		while (x<=120) {
	   		x, " : ", fac(x++)
		}
   }
fmode