home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
jambtm02.exe
/
FACTORIA.BTM
< prev
next >
Wrap
Text File
|
1992-11-15
|
951b
|
29 lines
*REM This batch file is Freeware, free to use and redistribute unmodified *
*REM Jouni Miettunen * jon@stekt.oulu.fi * Oulu * Finland * Europe * 1992 *
REM Calculating factorial: N! = N * (N-1)! for N gt 1 and 0! == 1
REM Timestamp 15-Nov-1992
break on^setlocal^unalias *
iff %#==0 then^echo Usage: %@lower[%@name[%0]] number(s)^goto end^endiff
for %b in (%&) gosub kertoma^goto end
:kertoma
set a=%b^screen %_row 0 Factorial(%a):
iff %a==0 then^screen %_row 35 1n^return^endiff
iff %a lt 0 .or. %a gt 18 then^screen %_row 0 Factorial(%a):tCan't calculate factorial for %an^return^endiff
set total=1
:work
set total=%@eval[%total*%a]^set a=%@eval[%a-1]^if %a gt 1 goto work
screen %_row %@eval[36-%@len[%total]-%@int[%@eval[%@len[%total]/3]]]]
set plaza=%@eval[%@len[%total]%%3]^echos %@substr[%total,,%plaza]
for %q in (0 3 6 9 12) echos ` `%@substr[%total,%@eval[%plaza+%q],3]^echo.
return
:end
break off^quit