home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
batnmore.z!p
/
DECOMPOS.BTM
< prev
next >
Wrap
Text File
|
1992-11-15
|
2KB
|
57 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 Divide numbers into prime number factors
REM Some extra code added to get around 9 digit limit in IF/IFF comparisons
REM Timestamp 15-Nov-1992
break on^setlocal^unalias *^if %#==0 .or. "%1"=="-?" goto info
alias next `shift^if "%1" != "" goto work^goto end`
REM Reset variables back to defaults, check for negative numbers and zero
:work
set index=5^set test=%1^if %_column != 0 echo.
iff %@ascii[%test]==45 then^echos %test = -1^set test=%@eval[-1*%test]
elseiff %test=0 then^echo 0 = 0^next %1^else^echos %test = 1^endiff
REM Process even numbers
:2loop
if %@eval[%test%%%2] != 0 goto 3loop^echos ` `* 2^set test=%@eval[%test/2]
goto 2loop
REM Divide numbers by three, special case to speed up things
:3loop
if %@eval[%test%%%3] != 0 goto loop^echos ` `* 3^set test=%@eval[%test/3]
goto 3loop
REM the main loop, check if there are more numbers in queue
:loop
iff %@eval[%test%%%%index] != 0 then
iff %test==1 then^next %1^endiff
set index=%@eval[%index+2+(%index+1)%%3]^goto loop
else^echos ` `* %index^set test=%@eval[%test/%index]^endiff
goto loop
:info
echo Usage:%@lower[%@name[%0]] number(s)
echo.
echo Divides numbers into prime number factors
:end
break off^quit
REM Well, even more optimized C code isn't fast enough.. Need info about MPQS
REM "the fastest currently known general factoring algoritm" (1992). Anybody?
REM References for future inspirations:
REM 1987 Cohen,H. & Lenstra,A.K.: Implementation of a new primality test (and Suppelement). Math. Comp. 48: 103-121 and S1-S4
REM 1984 Cohen,H. & Lenstra,Jr.,H.W.: Primality testing and Jacobi sums. Math. Comp. 42: 297-330
REM 1975 Guy,R.K.: How to factor a number. Proc. Fifth Manitoba conf. Numerical Math. 49-89 (Congressus Numerantium, XVI, Winnipeg, Manitoba, 1976)
REM 1984 Williams,H.C.: Factoring on a computer. Math. Intelligencer 6: No. 3, 29-36
REM 1984 An overview of factoring. In _Advances in Cryptology_ (Edited by D.Chaum), 71-80 Plenum, New York, 1984