home *** CD-ROM | disk | FTP | other *** search
- 18-Jun-88 14:28:52-MDT,1623;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:28:49 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22213; Sat, 18 Jun 88 14:28:50 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24594; Sat, 18 Jun 88 14:28:48 MDT
- Date: Sat, 18 Jun 88 14:28:48 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182028.AA24594@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: Factor.ras
-
- program factor;
- (* Factors big numbers
-
- c. 1985 The Reed Institute
-
- ..... 88.01.11.rec
-
- *)
-
- Uses __Quickdraw;
- Link __David, __Extras ;
-
- Type Giant = Integer[50]; (* We can go up to 147 = 3*49 digits *)
-
- proc _init();
- { syscall(4);
- syscall(20,-1,"This factoring program finds all prime factors, except");
- syscall(4);
- syscall(20,-1,"decomposition beyond pseudoprimes is not performed.");
- syscall(4);
- syscall(20,-1,"Use mouse to exit a lengthy factorization.");
- syscall(4);
- syscall(4);
- };
-
- proc _main();
- var x,y,z,w,u:giant; found:integer;
- {
- syscall(4);
- syscall(20,-1,"Number to be factored: ");
- readg(x);
- watch();
- if (x[0]>1) or (x[1]>1) then
- { loop(,found:=0,,((x[0]=1) and (x[1]=1)) or (button()))
- { factor(x,u);
- divG(u,x);
- loop(,,,((u[0]=1) and (u[1]=1)) or (button()))
- { factor(u,w);
- if found=1 then syscall(20,-1," *"); writeG(w); found:=1;
- divG(w,u);
- };
- };
- } else { itoG(1,w); writeG(w); };
- syscall(4);
- arrow();
-
- };
-
-