HyperCard is a very flexible program (often referred to as a Swiss Army Knife) for the Macintosh. It has strong support of sound, graphics, but we will only be making use of its programming language - HyperTalk. When Apple first released HyperCard in 1987 it was distributed freely to Macintosh owners. Since that time it has gone through several marketing changes - at some points (including the present) it was not even shipped with new Macintoshes. (This seems to have been a function of Apple's relentless efforts to shoot itself in the foot.)
These programs are written as HyperTalk scripts. To use one of them start HyperCard and then select the New Button item from the Objects menu. If this menu is not visible or if you are unable to edit the button's script type the following sequence to change the user level:
¤M" (Where ¤ is
the Apple key between the space bar and the Option
key on the keyboard. The "message box" should appear
somewhere on the screen.set userlevel to 5" in the message
box and press the "return" key. The menu
bar should now include the Objects menu.Opt-¤-click).
A script editing window will appear. Copy the script into
the window and close the window. Now press the button
to run the program.
HyperCard supports integers which can have values as large as 263=9223372036854775808, so the largest number which can be used in most of these algorithms is about 3000000000.
The basic arithmetic operations, +, -, /,
are available from the keyboard. Note that the division
operator normally returns a floating point number
(eg 7/2 returns 3.5) so the answer should
be truncated with the trunc function
(eg trunc(7/2) returns 3).
The modular reduction operator is represented with the
mod keyword.
Examples:
(8 + 7) mod 13(5 * 4) mod 13trunc(7 / 2)GCD - A script which implements the GCD algorithm can be found in the file gcd.script.
The Russian Peasant method for modular exponentiation is implemented in the program found in powmod.script.
A script which implements the Pollard Rho method for integer factorization is contained in the file factorPR.script.