Article: 4997 of comp.sys.handhelds From: kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb) Subject: HP48: Factoring Integers Date: 21 Dec 90 15:36:54 GMT This routine factors integers into primes. The program does trial division by all numbers that are not true multiples of 2,3,5 or 7. The main work is done in mcode, so it is fast. You need ASC\-> to install it. [No you don't. Already installed. -jkh-] Happy Christmas and a merry new year, -KK --------------------------------------------------------------------- Author --------------------------------------------------------------------- Mail any suggestions or comments to kskalb@informatik.uni-erlangen.de --------------------------------------------------------------------- Usage --------------------------------------------------------------------- Input: Level 2: Number n to be factored (binary or real; n < 2^63) Level 1: Bound b (binary or real; b < 2^20) Output: Level 1: List of Factors If the program is sure that all numbers in the output list are indeed primes, the list will be tagged with a plus-sign. If the tag is missing, the last entry in the list might not be a prime. All divisors t of n with t<=b will be found. The entries in the result will be real, unless they are greater than 2^39. Note that this can only happen to the last number in the list. [Note: See FACTOR for application of Klaus' code. -jkh-] --------------------------------------------------------------------- Installation --------------------------------------------------------------------- [Note! This applies ONLY to the original source code, TRIAL.SRC; the TRIAL program on the disk is already "installed" and may be used directly, so you may ignore what follows. -jkh-] -- Download the following program to your HP48. -- Be sure that ASC/-> is accessible. -- Evaluate the downloaded object. -- A program named 'TRIAL' will appear on the current directory. --------------------------------------------------------------------- Warning --------------------------------------------------------------------- The program 'TRIAL' contains a code object. To my knowledge, programs containing code object can't be edited on the HP48 by standard means, so don't try it. --------------------------------------------------------------------- Disclaimer --------------------------------------------------------------------- This program makes use of undocumented low-level features of the HP48SX calculator, and may or may not cause loss of data, excessive battery drainage, and/or damage to the calculator hardware. The Author takes no responsibility whatsoever for any damage caused by the use of this program. This software is provided "as is" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including, but not limited to, THE IMPLIED WARRANTIES OF MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE. ------------------------------------------------------------------------------ Klaus Kalb | mail : IMMD1 / Martenstr. 3 / W-8520 Erlangen / Germany | email: kskalb@immd1.informatik.uni-erlangen.de ------------------------------------------------------------------------------