-------------------------------
3]Number Theory Workshop
3]By M. O. Vahle, Albuquerque, NM
-------------------------------

(Portions of program copyright (c) 1987, True Basic Inc.)

     This program is a collection of high precision integer routines
accessed through a calculator-like interface.
      The functions appearing on the input keypad include factorial,
primality testing, solution of modulo linear and quadratic equations, modulo
exponentiation along with the more standard add, multiply, divide, square
root, and mod.
      As an example of the use of this program, the linear equation solver
and modulo exponentiation function can be used to experiment with the
calculations prescribed by the RAS public encryption algorithm. Each of
these functions operates on the 10 registers used for input and storage.
Each register can be independently edited, scanned, and printed. Except for
number entry, the program is controlled by clicking the mouse on the
appropriate button.
     The size of the numbers that the program can handle is only limited by
the amount of memory on the computer and the patience of the user. For
example, 500 factorial is calculated in a few minutes and totals more than
1,100 digits.
     The program was written using "True Basic" and made into a stand-alone
program using "True Basic's Runtime Package."
     To use the program, double-click on the workshop icon. A title screen
with brief instruction will appear. Click the left mouse button to proceed.
After a brief wait, the main screen of the program will appear. The screen
is divided into a number of subareas. On the top left is a small on/off
button. Clicking on it will terminate the program. Since "True Basic" does
not support ^c termination of a program and the on/off button is not
examined when the program is calculating a result, there may be times when
there is no graceful way to stop the program.  For example, checking a large
number for primality can take many minutes, during which the on/off button
is not functional.
     Next to the on/off button is a window where error messages and
instruction are shown. For example, pressing a mode button will produce a
definition of the function in this area.  Below this area is a
representation of keypad used to select the individual functions. Pressing a
mode button, generates a sequence of prompting where each capital letter in
its definition must be assigned a number stored in one of the registers. The
assignment is made by clicking on the register holding the number you which
to substitute for the parameter. The prompts are shown in the area beneath
the keypad. On the left of the keypad area are the registers, labeled r0: to
r9:, used for storage, input and output. Clicking on a register, other than
during the prompting sequence, will open it for editing.
     A register when it is opened for editing, will have a ">" prompt in it.
If a number is entered, it will appear to the right of the prompt. Backspace
will delete the character to the left of the prompt and the "del" key will
delete to the right. The left and right tabs will move the prompt to the
beginning and end of the line respectively. A carriage return or clicking
the mouse will close the register. As a register is edited, the number of
digits in the number it is holding will be reported in the mode prompt area
on the bottom right of the screen. Since the numbers being held in a
register can be much larger then can be displayed in a register window the
numbers can be scrolled with the left and right arrow keys.
     Suppose you wish to calculate 50 factorial (i.e., 50*49*48*...*1).
Click on a register, say r0:, type in 50 and then press Return or click the
mouse. This will put the number 50 in register R0:. Next click on the !
(factorial mode key). The definition A=N! will appear in the top window. The
letter A will appear in the prompt box below the keypad. Click on a
register, say R1:, to receive this value. Note it is the output of factorial
of N. Next the letter N will appear in the prompt box. Since we want n to be
50 and this value is in R0:, click on R0:. You will then be prompted with
"ok," "can," or "redo" in the prompt window on the bottom right. Click on
the "OK" button to initiate the calculation. The "can" button will terminate
the command and the "redo" button will allow you to re-enter the
assignments. The value will be calculated and stored in r1:. Since 50! is
too large to display all at once, click on r1: to examine it. By using the
left and right arrow keys, the entire number can be examined. If you have a
printer, the "prt" mode button will allow you to print it.
     The following is a description of the functions.

    + : sum two numbers

    - : subtract two numbers

    X : multiply two numbers

    / : divide two numbers, giving their quotient and remainder

    mod : find the remainder on dividing one number by another

    gcd : find the greatest common divisor of two numbers

    lcm : find the least common multiple of two numbers

    lin : find the solution to the linear equation ax=b mod n

    ! : find the factorial of a number (i.e. n*(n-1)*(n-2)...2*1 )

    qua : find the solutions of the quadratic equation
        ax^2+bx+c=0 mod n

    ^ : find the power of a number modulo a number
         (i.e. d=a^b mod c)

    ? : check a number to see if it is prime

    sqr : find the integer square root of a number and the
          difference between its square and the original number

    clr :  clear the contents of a register

    prt : print the contents of a register

    mov : move the contents of one register to another

4]END OF TEXT
