File: while

package info (click to toggle)
kvirc2 2.1.3-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 16,308 kB
  • ctags: 9,533
  • sloc: cpp: 86,257; sh: 10,532; makefile: 631; perl: 419; ansic: 315; sed: 16
file content (16 lines) | stat: -rw-r--r-- 242 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# While torture

if($#==0 || !$isnumber($1))echo Need one numeric parameter
else {
	if($1 < 2){
		echo Factorial of $1 is 1.
		halt
	}
	%tmp = 2
	%fac = 1
	while(%tmp <= $1){
		%fac = %fac * %tmp
		%tmp++;
	}
	echo Factorial of $1 is %fac.
}