Home » Archimedes archive » Acorn User » AU 1995-11.adf » !Regulars » Regulars/StarInfo/Markwick/!Numbers/!Help

Regulars/StarInfo/Markwick/!Numbers/!Help

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1995-11.adf » !Regulars
Filename: Regulars/StarInfo/Markwick/!Numbers/!Help
Read OK:
File size: 1BC6 bytes
Load address: 0000
Exec address: 0000
File contents
***********************************************
*                                             *
*  Program (C) Andrew J Markwick 1994.        *
*  Musical entertainment by Duran Duran.      *
*                                             *
***********************************************
*    You'll find this file easier to read     *
*    if you put your monitor in Mode 16       *
*    and make it a full size !Edit window!    *
***********************************************




  Overview of task '!Numbers'
  ----------------------------   

  'Numbers' can calculate factorials and powers which would normally be impossible on a computer or a calculator.

  
  Loading
  -------

  When you load the program a box will immediately appear asking you for an expected number of digits. Usually just pressing 
<RETURN> or clicking 'OK' will do as 1000 digits is all right, but if you suspect that the calculation you want to do is going totake loads of digits then you'll need to type in a bigger number and then click 'OK' or press <RETURN>. 
  You can't do any calculations until you've set the maximum number of digits.


  The Bar Icon
  ------------

  Clicking the left button over the bar icon brings up the factorial engine, and clicking the right button brings up the power 
engine. The middle button brings up the Bar Menu from which you can either
 i.   show info about the program, 
 ii.  save the current calculated number,
 iii. display the factorial engine,
 iv.  display the power engine,
 v.   display this help file,
 vi.  open the stored number directory, or
 vii. quit the program.


  The Factorial Engine
  --------------------

  Just enter the number you wish to know the factorial of and either press <RETURN> or click on the 'Calculate' icon.


  The Power Engine
  ----------------

  Type into the boxes the power and the base to raise to this power, and either press <RETURN> or click the 'Calculate' icon.


  Intelligent Save
  ----------------

  If this option is selected then the program will automatically save the calculated number into the 'Numbers' directory inside 
the application directory (ie. '!Numbers.Numbers'), giving it a name which is appropriate to the calculation, eg. 2 to the power 100 would get filename '2�100' and 1000 factorial would get '1000fact'. Also, the resulting file is automatically sent to !Edit 
for inspection.
  If this option is not selected, a standard RISC-OS save box will appear when the calculation is complete.
  You can always save the last calculated result from the item 'Save Current' on the menu.


  How it works...
  ---------------

  I'll now attempt to explain the algorithm.
  When you load the program you specify the number of digits we'll call this x. This is the size of the array which is 
DIMensioned at the start of the program for storing the answer in. That's why if x isn't high enough the program complains about the array size. I thought about just DIMensioning an array to about 30000 digits and not telling you about it but I decided in 
the end to make it clear that the program has a maximum length for the answer - which you can change.
  So the first thing we do is DIMension an array with x elements.
  The whole algorithm depends on long multiplication. Consider the multiplication a*b. If you analyse this you'll discover that 
you in fact multiply every digit of a by b but with carry, and this is the essence of the algorithm.
  A loop is set up and every digit in the answer is multiplied by the base (for powers) or the next number up in sequence (for 
factorials). Then for each digit in the (current) answer a check is made to see if the 'digit' is greater than ten, and if it is the tens are subtracted from that 'digit' and added as ones onto the next 'digit'. If this goes above the current number of 
digits, the number of digits is changed and so on.
  This is easier to see with an example.

  Take 6! for example.
  The program will set up an array with 1000 elements (by default, although it'll only need 3 of them!)
  A 1 is put into X(0).  So X(0)=1, X(1)=0, X(2)=0. #digits=0
  Now a loop is enter from C=1 TO 6. Each digit is multiplied by C. So X(0)=1, X(1)=0, X(2)=0.
  Now each digit is checked to see if it's >= 10. It's not, so we loop.
  Obviously nothing interesting is going to happen until X(0)>=10.

    C       1       2       3       4
    X(0)    1       2       6       24

  So when C=4 , X(0)=24, now X(0) is divided by 10 and the integer result taken (=2), which is added to X(1). The 2 is then 
multiplied by 10 and subtracted from X(0). So now X(0)=4, X(1)=2, X(2)=0.
  Now C=5, so X(0)=20, X(1)=10, X(0)=0, which after carry becomes... X(0)=0, X(1)=2, X(2)=1.
  Finally, C=6, so X(0)=0, X(1)=12, X(2)=6, which after carry becomes... X(0)=0, X(1)=2, X(2)=7.
  Now the result is read backwards, ie X(2)X(1)X(0), or 720, which is of course 6!.

  Hopefully it should be obvious that the only difference for powers is that instead of multiplying every 'digit' of the answer 
by the loop number C, we multiply it by the 'base' number 'power' times, ie. the loop is C=1 TO power.

  Here's the algorithm.

   START
    DIM X(#expected digits)
    X()=0         ; set all elements to zero
    X(0)=1        ; set first element to 1
    T=0:B=0       ; #digits in answer (T)=0
    FOR C=1 TO A  ; loop either factorial or power number of times.
     IF factorial THEN
      K=C         ; multiplying number is loop number
     ELSE         ; it must be power
      K=V         ; multiplying number is always base
     ENDIF
     FOR E=0 TO T  ; loop #digits in answer times
      X(E)=X(E)*K  ; multiply all digits by K
     NEXT E
     REPEAT
      O=T
      FOR E=B TO T
       IF X(E)>9 PROCx   ; check for 'digit'>=10 and carry if so
      NEXT E             
     UNTIL O>=T          ; for all 'digits' currently in answer
     B=0
    NEXT C ; loop
   END
    :
    DEF PROCx             ; PROCedure to sort out carry
     H=INT(X(E)/10)       ; first determine number of tens
     IF H>(X(E)/10):H=H-1 
     X(E+1)=X(E+1)+H      ; then add tens to next digit
     X(E)=X(E)-(H*10)     ; next subtract from current digit
     IF (E+1)>T T=E+1:B=T ; now extend the number of digits in answer (T) if necessary.
    ENDPROC
    :

  It's worth mentioning that I made this myself, by the method which seemed most sensible to me. It's entirely possible that 
there's a better method for working these things out, but my way works so I'm happy.



*********************************************************************************************************************************

 If anyone needs to contact me the safest bet is my home address;

       7 Riversdene,
        Stokesley,
        Cleveland.
        TS9 5DD.

 Or, if it's during term time, I can be contacted by s(nail)-mail at;

       Hulme Hall,
        Oxford Place,
        Victoria Park,
        Manchester.
        M14 5RR.

     and by e(asy)-mail at;

       AJM@fs1.ma.umist.ac.uk


                                                                     Andrew J Markwick   7/10/94  1:33am.



00000000  0a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |.***************|
00000010  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000030  0a 2a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.*              |
00000040  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000050  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 2a  |               *|
00000060  0a 2a 20 20 50 72 6f 67  72 61 6d 20 28 43 29 20  |.*  Program (C) |
00000070  41 6e 64 72 65 77 20 4a  20 4d 61 72 6b 77 69 63  |Andrew J Markwic|
00000080  6b 20 31 39 39 34 2e 20  20 20 20 20 20 20 20 2a  |k 1994.        *|
00000090  0a 2a 20 20 4d 75 73 69  63 61 6c 20 65 6e 74 65  |.*  Musical ente|
000000a0  72 74 61 69 6e 6d 65 6e  74 20 62 79 20 44 75 72  |rtainment by Dur|
000000b0  61 6e 20 44 75 72 61 6e  2e 20 20 20 20 20 20 2a  |an Duran.      *|
000000c0  0a 2a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.*              |
000000d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000000e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 2a  |               *|
000000f0  0a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |.***************|
00000100  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000120  0a 2a 20 20 20 20 59 6f  75 27 6c 6c 20 66 69 6e  |.*    You'll fin|
00000130  64 20 74 68 69 73 20 66  69 6c 65 20 65 61 73 69  |d this file easi|
00000140  65 72 20 74 6f 20 72 65  61 64 20 20 20 20 20 2a  |er to read     *|
00000150  0a 2a 20 20 20 20 69 66  20 79 6f 75 20 70 75 74  |.*    if you put|
00000160  20 79 6f 75 72 20 6d 6f  6e 69 74 6f 72 20 69 6e  | your monitor in|
00000170  20 4d 6f 64 65 20 31 36  20 20 20 20 20 20 20 2a  | Mode 16       *|
00000180  0a 2a 20 20 20 20 61 6e  64 20 6d 61 6b 65 20 69  |.*    and make i|
00000190  74 20 61 20 66 75 6c 6c  20 73 69 7a 65 20 21 45  |t a full size !E|
000001a0  64 69 74 20 77 69 6e 64  6f 77 21 20 20 20 20 2a  |dit window!    *|
000001b0  0a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |.***************|
000001c0  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
000001e0  0a 0a 0a 0a 0a 20 20 4f  76 65 72 76 69 65 77 20  |.....  Overview |
000001f0  6f 66 20 74 61 73 6b 20  27 21 4e 75 6d 62 65 72  |of task '!Number|
00000200  73 27 0a 20 20 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |s'.  -----------|
00000210  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
00000220  2d 20 20 20 0a 0a 20 20  27 4e 75 6d 62 65 72 73  |-   ..  'Numbers|
00000230  27 20 63 61 6e 20 63 61  6c 63 75 6c 61 74 65 20  |' can calculate |
00000240  66 61 63 74 6f 72 69 61  6c 73 20 61 6e 64 20 70  |factorials and p|
00000250  6f 77 65 72 73 20 77 68  69 63 68 20 77 6f 75 6c  |owers which woul|
00000260  64 20 6e 6f 72 6d 61 6c  6c 79 20 62 65 20 69 6d  |d normally be im|
00000270  70 6f 73 73 69 62 6c 65  20 6f 6e 20 61 20 63 6f  |possible on a co|
00000280  6d 70 75 74 65 72 20 6f  72 20 61 20 63 61 6c 63  |mputer or a calc|
00000290  75 6c 61 74 6f 72 2e 0a  0a 20 20 0a 20 20 4c 6f  |ulator...  .  Lo|
000002a0  61 64 69 6e 67 0a 20 20  2d 2d 2d 2d 2d 2d 2d 0a  |ading.  -------.|
000002b0  0a 20 20 57 68 65 6e 20  79 6f 75 20 6c 6f 61 64  |.  When you load|
000002c0  20 74 68 65 20 70 72 6f  67 72 61 6d 20 61 20 62  | the program a b|
000002d0  6f 78 20 77 69 6c 6c 20  69 6d 6d 65 64 69 61 74  |ox will immediat|
000002e0  65 6c 79 20 61 70 70 65  61 72 20 61 73 6b 69 6e  |ely appear askin|
000002f0  67 20 79 6f 75 20 66 6f  72 20 61 6e 20 65 78 70  |g you for an exp|
00000300  65 63 74 65 64 20 6e 75  6d 62 65 72 20 6f 66 20  |ected number of |
00000310  64 69 67 69 74 73 2e 20  55 73 75 61 6c 6c 79 20  |digits. Usually |
00000320  6a 75 73 74 20 70 72 65  73 73 69 6e 67 20 0a 3c  |just pressing .<|
00000330  52 45 54 55 52 4e 3e 20  6f 72 20 63 6c 69 63 6b  |RETURN> or click|
00000340  69 6e 67 20 27 4f 4b 27  20 77 69 6c 6c 20 64 6f  |ing 'OK' will do|
00000350  20 61 73 20 31 30 30 30  20 64 69 67 69 74 73 20  | as 1000 digits |
00000360  69 73 20 61 6c 6c 20 72  69 67 68 74 2c 20 62 75  |is all right, bu|
00000370  74 20 69 66 20 79 6f 75  20 73 75 73 70 65 63 74  |t if you suspect|
00000380  20 74 68 61 74 20 74 68  65 20 63 61 6c 63 75 6c  | that the calcul|
00000390  61 74 69 6f 6e 20 79 6f  75 20 77 61 6e 74 20 74  |ation you want t|
000003a0  6f 20 64 6f 20 69 73 20  67 6f 69 6e 67 20 74 6f  |o do is going to|
000003b0  74 61 6b 65 20 6c 6f 61  64 73 20 6f 66 20 64 69  |take loads of di|
000003c0  67 69 74 73 20 74 68 65  6e 20 79 6f 75 27 6c 6c  |gits then you'll|
000003d0  20 6e 65 65 64 20 74 6f  20 74 79 70 65 20 69 6e  | need to type in|
000003e0  20 61 20 62 69 67 67 65  72 20 6e 75 6d 62 65 72  | a bigger number|
000003f0  20 61 6e 64 20 74 68 65  6e 20 63 6c 69 63 6b 20  | and then click |
00000400  27 4f 4b 27 20 6f 72 20  70 72 65 73 73 20 3c 52  |'OK' or press <R|
00000410  45 54 55 52 4e 3e 2e 20  0a 20 20 59 6f 75 20 63  |ETURN>. .  You c|
00000420  61 6e 27 74 20 64 6f 20  61 6e 79 20 63 61 6c 63  |an't do any calc|
00000430  75 6c 61 74 69 6f 6e 73  20 75 6e 74 69 6c 20 79  |ulations until y|
00000440  6f 75 27 76 65 20 73 65  74 20 74 68 65 20 6d 61  |ou've set the ma|
00000450  78 69 6d 75 6d 20 6e 75  6d 62 65 72 20 6f 66 20  |ximum number of |
00000460  64 69 67 69 74 73 2e 0a  0a 0a 20 20 54 68 65 20  |digits....  The |
00000470  42 61 72 20 49 63 6f 6e  0a 20 20 2d 2d 2d 2d 2d  |Bar Icon.  -----|
00000480  2d 2d 2d 2d 2d 2d 2d 0a  0a 20 20 43 6c 69 63 6b  |-------..  Click|
00000490  69 6e 67 20 74 68 65 20  6c 65 66 74 20 62 75 74  |ing the left but|
000004a0  74 6f 6e 20 6f 76 65 72  20 74 68 65 20 62 61 72  |ton over the bar|
000004b0  20 69 63 6f 6e 20 62 72  69 6e 67 73 20 75 70 20  | icon brings up |
000004c0  74 68 65 20 66 61 63 74  6f 72 69 61 6c 20 65 6e  |the factorial en|
000004d0  67 69 6e 65 2c 20 61 6e  64 20 63 6c 69 63 6b 69  |gine, and clicki|
000004e0  6e 67 20 74 68 65 20 72  69 67 68 74 20 62 75 74  |ng the right but|
000004f0  74 6f 6e 20 62 72 69 6e  67 73 20 75 70 20 74 68  |ton brings up th|
00000500  65 20 70 6f 77 65 72 20  0a 65 6e 67 69 6e 65 2e  |e power .engine.|
00000510  20 54 68 65 20 6d 69 64  64 6c 65 20 62 75 74 74  | The middle butt|
00000520  6f 6e 20 62 72 69 6e 67  73 20 75 70 20 74 68 65  |on brings up the|
00000530  20 42 61 72 20 4d 65 6e  75 20 66 72 6f 6d 20 77  | Bar Menu from w|
00000540  68 69 63 68 20 79 6f 75  20 63 61 6e 20 65 69 74  |hich you can eit|
00000550  68 65 72 0a 20 69 2e 20  20 20 73 68 6f 77 20 69  |her. i.   show i|
00000560  6e 66 6f 20 61 62 6f 75  74 20 74 68 65 20 70 72  |nfo about the pr|
00000570  6f 67 72 61 6d 2c 20 0a  20 69 69 2e 20 20 73 61  |ogram, . ii.  sa|
00000580  76 65 20 74 68 65 20 63  75 72 72 65 6e 74 20 63  |ve the current c|
00000590  61 6c 63 75 6c 61 74 65  64 20 6e 75 6d 62 65 72  |alculated number|
000005a0  2c 0a 20 69 69 69 2e 20  64 69 73 70 6c 61 79 20  |,. iii. display |
000005b0  74 68 65 20 66 61 63 74  6f 72 69 61 6c 20 65 6e  |the factorial en|
000005c0  67 69 6e 65 2c 0a 20 69  76 2e 20 20 64 69 73 70  |gine,. iv.  disp|
000005d0  6c 61 79 20 74 68 65 20  70 6f 77 65 72 20 65 6e  |lay the power en|
000005e0  67 69 6e 65 2c 0a 20 76  2e 20 20 20 64 69 73 70  |gine,. v.   disp|
000005f0  6c 61 79 20 74 68 69 73  20 68 65 6c 70 20 66 69  |lay this help fi|
00000600  6c 65 2c 0a 20 76 69 2e  20 20 6f 70 65 6e 20 74  |le,. vi.  open t|
00000610  68 65 20 73 74 6f 72 65  64 20 6e 75 6d 62 65 72  |he stored number|
00000620  20 64 69 72 65 63 74 6f  72 79 2c 20 6f 72 0a 20  | directory, or. |
00000630  76 69 69 2e 20 71 75 69  74 20 74 68 65 20 70 72  |vii. quit the pr|
00000640  6f 67 72 61 6d 2e 0a 0a  0a 20 20 54 68 65 20 46  |ogram....  The F|
00000650  61 63 74 6f 72 69 61 6c  20 45 6e 67 69 6e 65 0a  |actorial Engine.|
00000660  20 20 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |  --------------|
00000670  2d 2d 2d 2d 2d 2d 0a 0a  20 20 4a 75 73 74 20 65  |------..  Just e|
00000680  6e 74 65 72 20 74 68 65  20 6e 75 6d 62 65 72 20  |nter the number |
00000690  79 6f 75 20 77 69 73 68  20 74 6f 20 6b 6e 6f 77  |you wish to know|
000006a0  20 74 68 65 20 66 61 63  74 6f 72 69 61 6c 20 6f  | the factorial o|
000006b0  66 20 61 6e 64 20 65 69  74 68 65 72 20 70 72 65  |f and either pre|
000006c0  73 73 20 3c 52 45 54 55  52 4e 3e 20 6f 72 20 63  |ss <RETURN> or c|
000006d0  6c 69 63 6b 20 6f 6e 20  74 68 65 20 27 43 61 6c  |lick on the 'Cal|
000006e0  63 75 6c 61 74 65 27 20  69 63 6f 6e 2e 0a 0a 0a  |culate' icon....|
000006f0  20 20 54 68 65 20 50 6f  77 65 72 20 45 6e 67 69  |  The Power Engi|
00000700  6e 65 0a 20 20 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |ne.  -----------|
00000710  2d 2d 2d 2d 2d 0a 0a 20  20 54 79 70 65 20 69 6e  |-----..  Type in|
00000720  74 6f 20 74 68 65 20 62  6f 78 65 73 20 74 68 65  |to the boxes the|
00000730  20 70 6f 77 65 72 20 61  6e 64 20 74 68 65 20 62  | power and the b|
00000740  61 73 65 20 74 6f 20 72  61 69 73 65 20 74 6f 20  |ase to raise to |
00000750  74 68 69 73 20 70 6f 77  65 72 2c 20 61 6e 64 20  |this power, and |
00000760  65 69 74 68 65 72 20 70  72 65 73 73 20 3c 52 45  |either press <RE|
00000770  54 55 52 4e 3e 20 6f 72  20 63 6c 69 63 6b 20 74  |TURN> or click t|
00000780  68 65 20 27 43 61 6c 63  75 6c 61 74 65 27 20 69  |he 'Calculate' i|
00000790  63 6f 6e 2e 0a 0a 0a 20  20 49 6e 74 65 6c 6c 69  |con....  Intelli|
000007a0  67 65 6e 74 20 53 61 76  65 0a 20 20 2d 2d 2d 2d  |gent Save.  ----|
000007b0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 0a 0a 20 20  |------------..  |
000007c0  49 66 20 74 68 69 73 20  6f 70 74 69 6f 6e 20 69  |If this option i|
000007d0  73 20 73 65 6c 65 63 74  65 64 20 74 68 65 6e 20  |s selected then |
000007e0  74 68 65 20 70 72 6f 67  72 61 6d 20 77 69 6c 6c  |the program will|
000007f0  20 61 75 74 6f 6d 61 74  69 63 61 6c 6c 79 20 73  | automatically s|
00000800  61 76 65 20 74 68 65 20  63 61 6c 63 75 6c 61 74  |ave the calculat|
00000810  65 64 20 6e 75 6d 62 65  72 20 69 6e 74 6f 20 74  |ed number into t|
00000820  68 65 20 27 4e 75 6d 62  65 72 73 27 20 64 69 72  |he 'Numbers' dir|
00000830  65 63 74 6f 72 79 20 69  6e 73 69 64 65 20 0a 74  |ectory inside .t|
00000840  68 65 20 61 70 70 6c 69  63 61 74 69 6f 6e 20 64  |he application d|
00000850  69 72 65 63 74 6f 72 79  20 28 69 65 2e 20 27 21  |irectory (ie. '!|
00000860  4e 75 6d 62 65 72 73 2e  4e 75 6d 62 65 72 73 27  |Numbers.Numbers'|
00000870  29 2c 20 67 69 76 69 6e  67 20 69 74 20 61 20 6e  |), giving it a n|
00000880  61 6d 65 20 77 68 69 63  68 20 69 73 20 61 70 70  |ame which is app|
00000890  72 6f 70 72 69 61 74 65  20 74 6f 20 74 68 65 20  |ropriate to the |
000008a0  63 61 6c 63 75 6c 61 74  69 6f 6e 2c 20 65 67 2e  |calculation, eg.|
000008b0  20 32 20 74 6f 20 74 68  65 20 70 6f 77 65 72 20  | 2 to the power |
000008c0  31 30 30 20 77 6f 75 6c  64 20 67 65 74 20 66 69  |100 would get fi|
000008d0  6c 65 6e 61 6d 65 20 27  32 8b 31 30 30 27 20 61  |lename '2.100' a|
000008e0  6e 64 20 31 30 30 30 20  66 61 63 74 6f 72 69 61  |nd 1000 factoria|
000008f0  6c 20 77 6f 75 6c 64 20  67 65 74 20 27 31 30 30  |l would get '100|
00000900  30 66 61 63 74 27 2e 20  41 6c 73 6f 2c 20 74 68  |0fact'. Also, th|
00000910  65 20 72 65 73 75 6c 74  69 6e 67 20 66 69 6c 65  |e resulting file|
00000920  20 69 73 20 61 75 74 6f  6d 61 74 69 63 61 6c 6c  | is automaticall|
00000930  79 20 73 65 6e 74 20 74  6f 20 21 45 64 69 74 20  |y sent to !Edit |
00000940  0a 66 6f 72 20 69 6e 73  70 65 63 74 69 6f 6e 2e  |.for inspection.|
00000950  0a 20 20 49 66 20 74 68  69 73 20 6f 70 74 69 6f  |.  If this optio|
00000960  6e 20 69 73 20 6e 6f 74  20 73 65 6c 65 63 74 65  |n is not selecte|
00000970  64 2c 20 61 20 73 74 61  6e 64 61 72 64 20 52 49  |d, a standard RI|
00000980  53 43 2d 4f 53 20 73 61  76 65 20 62 6f 78 20 77  |SC-OS save box w|
00000990  69 6c 6c 20 61 70 70 65  61 72 20 77 68 65 6e 20  |ill appear when |
000009a0  74 68 65 20 63 61 6c 63  75 6c 61 74 69 6f 6e 20  |the calculation |
000009b0  69 73 20 63 6f 6d 70 6c  65 74 65 2e 0a 20 20 59  |is complete..  Y|
000009c0  6f 75 20 63 61 6e 20 61  6c 77 61 79 73 20 73 61  |ou can always sa|
000009d0  76 65 20 74 68 65 20 6c  61 73 74 20 63 61 6c 63  |ve the last calc|
000009e0  75 6c 61 74 65 64 20 72  65 73 75 6c 74 20 66 72  |ulated result fr|
000009f0  6f 6d 20 74 68 65 20 69  74 65 6d 20 27 53 61 76  |om the item 'Sav|
00000a00  65 20 43 75 72 72 65 6e  74 27 20 6f 6e 20 74 68  |e Current' on th|
00000a10  65 20 6d 65 6e 75 2e 0a  0a 0a 20 20 48 6f 77 20  |e menu....  How |
00000a20  69 74 20 77 6f 72 6b 73  2e 2e 2e 0a 20 20 2d 2d  |it works....  --|
00000a30  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 0a 0a 20  |-------------.. |
00000a40  20 49 27 6c 6c 20 6e 6f  77 20 61 74 74 65 6d 70  | I'll now attemp|
00000a50  74 20 74 6f 20 65 78 70  6c 61 69 6e 20 74 68 65  |t to explain the|
00000a60  20 61 6c 67 6f 72 69 74  68 6d 2e 0a 20 20 57 68  | algorithm..  Wh|
00000a70  65 6e 20 79 6f 75 20 6c  6f 61 64 20 74 68 65 20  |en you load the |
00000a80  70 72 6f 67 72 61 6d 20  79 6f 75 20 73 70 65 63  |program you spec|
00000a90  69 66 79 20 74 68 65 20  6e 75 6d 62 65 72 20 6f  |ify the number o|
00000aa0  66 20 64 69 67 69 74 73  20 77 65 27 6c 6c 20 63  |f digits we'll c|
00000ab0  61 6c 6c 20 74 68 69 73  20 78 2e 20 54 68 69 73  |all this x. This|
00000ac0  20 69 73 20 74 68 65 20  73 69 7a 65 20 6f 66 20  | is the size of |
00000ad0  74 68 65 20 61 72 72 61  79 20 77 68 69 63 68 20  |the array which |
00000ae0  69 73 20 0a 44 49 4d 65  6e 73 69 6f 6e 65 64 20  |is .DIMensioned |
00000af0  61 74 20 74 68 65 20 73  74 61 72 74 20 6f 66 20  |at the start of |
00000b00  74 68 65 20 70 72 6f 67  72 61 6d 20 66 6f 72 20  |the program for |
00000b10  73 74 6f 72 69 6e 67 20  74 68 65 20 61 6e 73 77  |storing the answ|
00000b20  65 72 20 69 6e 2e 20 54  68 61 74 27 73 20 77 68  |er in. That's wh|
00000b30  79 20 69 66 20 78 20 69  73 6e 27 74 20 68 69 67  |y if x isn't hig|
00000b40  68 20 65 6e 6f 75 67 68  20 74 68 65 20 70 72 6f  |h enough the pro|
00000b50  67 72 61 6d 20 63 6f 6d  70 6c 61 69 6e 73 20 61  |gram complains a|
00000b60  62 6f 75 74 20 74 68 65  20 61 72 72 61 79 20 73  |bout the array s|
00000b70  69 7a 65 2e 20 49 20 74  68 6f 75 67 68 74 20 61  |ize. I thought a|
00000b80  62 6f 75 74 20 6a 75 73  74 20 44 49 4d 65 6e 73  |bout just DIMens|
00000b90  69 6f 6e 69 6e 67 20 61  6e 20 61 72 72 61 79 20  |ioning an array |
00000ba0  74 6f 20 61 62 6f 75 74  20 33 30 30 30 30 20 64  |to about 30000 d|
00000bb0  69 67 69 74 73 20 61 6e  64 20 6e 6f 74 20 74 65  |igits and not te|
00000bc0  6c 6c 69 6e 67 20 79 6f  75 20 61 62 6f 75 74 20  |lling you about |
00000bd0  69 74 20 62 75 74 20 49  20 64 65 63 69 64 65 64  |it but I decided|
00000be0  20 69 6e 20 0a 74 68 65  20 65 6e 64 20 74 6f 20  | in .the end to |
00000bf0  6d 61 6b 65 20 69 74 20  63 6c 65 61 72 20 74 68  |make it clear th|
00000c00  61 74 20 74 68 65 20 70  72 6f 67 72 61 6d 20 68  |at the program h|
00000c10  61 73 20 61 20 6d 61 78  69 6d 75 6d 20 6c 65 6e  |as a maximum len|
00000c20  67 74 68 20 66 6f 72 20  74 68 65 20 61 6e 73 77  |gth for the answ|
00000c30  65 72 20 2d 20 77 68 69  63 68 20 79 6f 75 20 63  |er - which you c|
00000c40  61 6e 20 63 68 61 6e 67  65 2e 0a 20 20 53 6f 20  |an change..  So |
00000c50  74 68 65 20 66 69 72 73  74 20 74 68 69 6e 67 20  |the first thing |
00000c60  77 65 20 64 6f 20 69 73  20 44 49 4d 65 6e 73 69  |we do is DIMensi|
00000c70  6f 6e 20 61 6e 20 61 72  72 61 79 20 77 69 74 68  |on an array with|
00000c80  20 78 20 65 6c 65 6d 65  6e 74 73 2e 0a 20 20 54  | x elements..  T|
00000c90  68 65 20 77 68 6f 6c 65  20 61 6c 67 6f 72 69 74  |he whole algorit|
00000ca0  68 6d 20 64 65 70 65 6e  64 73 20 6f 6e 20 6c 6f  |hm depends on lo|
00000cb0  6e 67 20 6d 75 6c 74 69  70 6c 69 63 61 74 69 6f  |ng multiplicatio|
00000cc0  6e 2e 20 43 6f 6e 73 69  64 65 72 20 74 68 65 20  |n. Consider the |
00000cd0  6d 75 6c 74 69 70 6c 69  63 61 74 69 6f 6e 20 61  |multiplication a|
00000ce0  2a 62 2e 20 49 66 20 79  6f 75 20 61 6e 61 6c 79  |*b. If you analy|
00000cf0  73 65 20 74 68 69 73 20  79 6f 75 27 6c 6c 20 64  |se this you'll d|
00000d00  69 73 63 6f 76 65 72 20  74 68 61 74 20 0a 79 6f  |iscover that .yo|
00000d10  75 20 69 6e 20 66 61 63  74 20 6d 75 6c 74 69 70  |u in fact multip|
00000d20  6c 79 20 65 76 65 72 79  20 64 69 67 69 74 20 6f  |ly every digit o|
00000d30  66 20 61 20 62 79 20 62  20 62 75 74 20 77 69 74  |f a by b but wit|
00000d40  68 20 63 61 72 72 79 2c  20 61 6e 64 20 74 68 69  |h carry, and thi|
00000d50  73 20 69 73 20 74 68 65  20 65 73 73 65 6e 63 65  |s is the essence|
00000d60  20 6f 66 20 74 68 65 20  61 6c 67 6f 72 69 74 68  | of the algorith|
00000d70  6d 2e 0a 20 20 41 20 6c  6f 6f 70 20 69 73 20 73  |m..  A loop is s|
00000d80  65 74 20 75 70 20 61 6e  64 20 65 76 65 72 79 20  |et up and every |
00000d90  64 69 67 69 74 20 69 6e  20 74 68 65 20 61 6e 73  |digit in the ans|
00000da0  77 65 72 20 69 73 20 6d  75 6c 74 69 70 6c 69 65  |wer is multiplie|
00000db0  64 20 62 79 20 74 68 65  20 62 61 73 65 20 28 66  |d by the base (f|
00000dc0  6f 72 20 70 6f 77 65 72  73 29 20 6f 72 20 74 68  |or powers) or th|
00000dd0  65 20 6e 65 78 74 20 6e  75 6d 62 65 72 20 75 70  |e next number up|
00000de0  20 69 6e 20 73 65 71 75  65 6e 63 65 20 28 66 6f  | in sequence (fo|
00000df0  72 20 0a 66 61 63 74 6f  72 69 61 6c 73 29 2e 20  |r .factorials). |
00000e00  54 68 65 6e 20 66 6f 72  20 65 61 63 68 20 64 69  |Then for each di|
00000e10  67 69 74 20 69 6e 20 74  68 65 20 28 63 75 72 72  |git in the (curr|
00000e20  65 6e 74 29 20 61 6e 73  77 65 72 20 61 20 63 68  |ent) answer a ch|
00000e30  65 63 6b 20 69 73 20 6d  61 64 65 20 74 6f 20 73  |eck is made to s|
00000e40  65 65 20 69 66 20 74 68  65 20 27 64 69 67 69 74  |ee if the 'digit|
00000e50  27 20 69 73 20 67 72 65  61 74 65 72 20 74 68 61  |' is greater tha|
00000e60  6e 20 74 65 6e 2c 20 61  6e 64 20 69 66 20 69 74  |n ten, and if it|
00000e70  20 69 73 20 74 68 65 20  74 65 6e 73 20 61 72 65  | is the tens are|
00000e80  20 73 75 62 74 72 61 63  74 65 64 20 66 72 6f 6d  | subtracted from|
00000e90  20 74 68 61 74 20 27 64  69 67 69 74 27 20 61 6e  | that 'digit' an|
00000ea0  64 20 61 64 64 65 64 20  61 73 20 6f 6e 65 73 20  |d added as ones |
00000eb0  6f 6e 74 6f 20 74 68 65  20 6e 65 78 74 20 27 64  |onto the next 'd|
00000ec0  69 67 69 74 27 2e 20 49  66 20 74 68 69 73 20 67  |igit'. If this g|
00000ed0  6f 65 73 20 61 62 6f 76  65 20 74 68 65 20 63 75  |oes above the cu|
00000ee0  72 72 65 6e 74 20 6e 75  6d 62 65 72 20 6f 66 20  |rrent number of |
00000ef0  0a 64 69 67 69 74 73 2c  20 74 68 65 20 6e 75 6d  |.digits, the num|
00000f00  62 65 72 20 6f 66 20 64  69 67 69 74 73 20 69 73  |ber of digits is|
00000f10  20 63 68 61 6e 67 65 64  20 61 6e 64 20 73 6f 20  | changed and so |
00000f20  6f 6e 2e 0a 20 20 54 68  69 73 20 69 73 20 65 61  |on..  This is ea|
00000f30  73 69 65 72 20 74 6f 20  73 65 65 20 77 69 74 68  |sier to see with|
00000f40  20 61 6e 20 65 78 61 6d  70 6c 65 2e 0a 0a 20 20  | an example...  |
00000f50  54 61 6b 65 20 36 21 20  66 6f 72 20 65 78 61 6d  |Take 6! for exam|
00000f60  70 6c 65 2e 0a 20 20 54  68 65 20 70 72 6f 67 72  |ple..  The progr|
00000f70  61 6d 20 77 69 6c 6c 20  73 65 74 20 75 70 20 61  |am will set up a|
00000f80  6e 20 61 72 72 61 79 20  77 69 74 68 20 31 30 30  |n array with 100|
00000f90  30 20 65 6c 65 6d 65 6e  74 73 20 28 62 79 20 64  |0 elements (by d|
00000fa0  65 66 61 75 6c 74 2c 20  61 6c 74 68 6f 75 67 68  |efault, although|
00000fb0  20 69 74 27 6c 6c 20 6f  6e 6c 79 20 6e 65 65 64  | it'll only need|
00000fc0  20 33 20 6f 66 20 74 68  65 6d 21 29 0a 20 20 41  | 3 of them!).  A|
00000fd0  20 31 20 69 73 20 70 75  74 20 69 6e 74 6f 20 58  | 1 is put into X|
00000fe0  28 30 29 2e 20 20 53 6f  20 58 28 30 29 3d 31 2c  |(0).  So X(0)=1,|
00000ff0  20 58 28 31 29 3d 30 2c  20 58 28 32 29 3d 30 2e  | X(1)=0, X(2)=0.|
00001000  20 23 64 69 67 69 74 73  3d 30 0a 20 20 4e 6f 77  | #digits=0.  Now|
00001010  20 61 20 6c 6f 6f 70 20  69 73 20 65 6e 74 65 72  | a loop is enter|
00001020  20 66 72 6f 6d 20 43 3d  31 20 54 4f 20 36 2e 20  | from C=1 TO 6. |
00001030  45 61 63 68 20 64 69 67  69 74 20 69 73 20 6d 75  |Each digit is mu|
00001040  6c 74 69 70 6c 69 65 64  20 62 79 20 43 2e 20 53  |ltiplied by C. S|
00001050  6f 20 58 28 30 29 3d 31  2c 20 58 28 31 29 3d 30  |o X(0)=1, X(1)=0|
00001060  2c 20 58 28 32 29 3d 30  2e 0a 20 20 4e 6f 77 20  |, X(2)=0..  Now |
00001070  65 61 63 68 20 64 69 67  69 74 20 69 73 20 63 68  |each digit is ch|
00001080  65 63 6b 65 64 20 74 6f  20 73 65 65 20 69 66 20  |ecked to see if |
00001090  69 74 27 73 20 3e 3d 20  31 30 2e 20 49 74 27 73  |it's >= 10. It's|
000010a0  20 6e 6f 74 2c 20 73 6f  20 77 65 20 6c 6f 6f 70  | not, so we loop|
000010b0  2e 0a 20 20 4f 62 76 69  6f 75 73 6c 79 20 6e 6f  |..  Obviously no|
000010c0  74 68 69 6e 67 20 69 6e  74 65 72 65 73 74 69 6e  |thing interestin|
000010d0  67 20 69 73 20 67 6f 69  6e 67 20 74 6f 20 68 61  |g is going to ha|
000010e0  70 70 65 6e 20 75 6e 74  69 6c 20 58 28 30 29 3e  |ppen until X(0)>|
000010f0  3d 31 30 2e 0a 0a 20 20  20 20 43 20 20 20 20 20  |=10...    C     |
00001100  20 20 31 20 20 20 20 20  20 20 32 20 20 20 20 20  |  1       2     |
00001110  20 20 33 20 20 20 20 20  20 20 34 0a 20 20 20 20  |  3       4.    |
00001120  58 28 30 29 20 20 20 20  31 20 20 20 20 20 20 20  |X(0)    1       |
00001130  32 20 20 20 20 20 20 20  36 20 20 20 20 20 20 20  |2       6       |
00001140  32 34 0a 0a 20 20 53 6f  20 77 68 65 6e 20 43 3d  |24..  So when C=|
00001150  34 20 2c 20 58 28 30 29  3d 32 34 2c 20 6e 6f 77  |4 , X(0)=24, now|
00001160  20 58 28 30 29 20 69 73  20 64 69 76 69 64 65 64  | X(0) is divided|
00001170  20 62 79 20 31 30 20 61  6e 64 20 74 68 65 20 69  | by 10 and the i|
00001180  6e 74 65 67 65 72 20 72  65 73 75 6c 74 20 74 61  |nteger result ta|
00001190  6b 65 6e 20 28 3d 32 29  2c 20 77 68 69 63 68 20  |ken (=2), which |
000011a0  69 73 20 61 64 64 65 64  20 74 6f 20 58 28 31 29  |is added to X(1)|
000011b0  2e 20 54 68 65 20 32 20  69 73 20 74 68 65 6e 20  |. The 2 is then |
000011c0  0a 6d 75 6c 74 69 70 6c  69 65 64 20 62 79 20 31  |.multiplied by 1|
000011d0  30 20 61 6e 64 20 73 75  62 74 72 61 63 74 65 64  |0 and subtracted|
000011e0  20 66 72 6f 6d 20 58 28  30 29 2e 20 53 6f 20 6e  | from X(0). So n|
000011f0  6f 77 20 58 28 30 29 3d  34 2c 20 58 28 31 29 3d  |ow X(0)=4, X(1)=|
00001200  32 2c 20 58 28 32 29 3d  30 2e 0a 20 20 4e 6f 77  |2, X(2)=0..  Now|
00001210  20 43 3d 35 2c 20 73 6f  20 58 28 30 29 3d 32 30  | C=5, so X(0)=20|
00001220  2c 20 58 28 31 29 3d 31  30 2c 20 58 28 30 29 3d  |, X(1)=10, X(0)=|
00001230  30 2c 20 77 68 69 63 68  20 61 66 74 65 72 20 63  |0, which after c|
00001240  61 72 72 79 20 62 65 63  6f 6d 65 73 2e 2e 2e 20  |arry becomes... |
00001250  58 28 30 29 3d 30 2c 20  58 28 31 29 3d 32 2c 20  |X(0)=0, X(1)=2, |
00001260  58 28 32 29 3d 31 2e 0a  20 20 46 69 6e 61 6c 6c  |X(2)=1..  Finall|
00001270  79 2c 20 43 3d 36 2c 20  73 6f 20 58 28 30 29 3d  |y, C=6, so X(0)=|
00001280  30 2c 20 58 28 31 29 3d  31 32 2c 20 58 28 32 29  |0, X(1)=12, X(2)|
00001290  3d 36 2c 20 77 68 69 63  68 20 61 66 74 65 72 20  |=6, which after |
000012a0  63 61 72 72 79 20 62 65  63 6f 6d 65 73 2e 2e 2e  |carry becomes...|
000012b0  20 58 28 30 29 3d 30 2c  20 58 28 31 29 3d 32 2c  | X(0)=0, X(1)=2,|
000012c0  20 58 28 32 29 3d 37 2e  0a 20 20 4e 6f 77 20 74  | X(2)=7..  Now t|
000012d0  68 65 20 72 65 73 75 6c  74 20 69 73 20 72 65 61  |he result is rea|
000012e0  64 20 62 61 63 6b 77 61  72 64 73 2c 20 69 65 20  |d backwards, ie |
000012f0  58 28 32 29 58 28 31 29  58 28 30 29 2c 20 6f 72  |X(2)X(1)X(0), or|
00001300  20 37 32 30 2c 20 77 68  69 63 68 20 69 73 20 6f  | 720, which is o|
00001310  66 20 63 6f 75 72 73 65  20 36 21 2e 0a 0a 20 20  |f course 6!...  |
00001320  48 6f 70 65 66 75 6c 6c  79 20 69 74 20 73 68 6f  |Hopefully it sho|
00001330  75 6c 64 20 62 65 20 6f  62 76 69 6f 75 73 20 74  |uld be obvious t|
00001340  68 61 74 20 74 68 65 20  6f 6e 6c 79 20 64 69 66  |hat the only dif|
00001350  66 65 72 65 6e 63 65 20  66 6f 72 20 70 6f 77 65  |ference for powe|
00001360  72 73 20 69 73 20 74 68  61 74 20 69 6e 73 74 65  |rs is that inste|
00001370  61 64 20 6f 66 20 6d 75  6c 74 69 70 6c 79 69 6e  |ad of multiplyin|
00001380  67 20 65 76 65 72 79 20  27 64 69 67 69 74 27 20  |g every 'digit' |
00001390  6f 66 20 74 68 65 20 61  6e 73 77 65 72 20 0a 62  |of the answer .b|
000013a0  79 20 74 68 65 20 6c 6f  6f 70 20 6e 75 6d 62 65  |y the loop numbe|
000013b0  72 20 43 2c 20 77 65 20  6d 75 6c 74 69 70 6c 79  |r C, we multiply|
000013c0  20 69 74 20 62 79 20 74  68 65 20 27 62 61 73 65  | it by the 'base|
000013d0  27 20 6e 75 6d 62 65 72  20 27 70 6f 77 65 72 27  |' number 'power'|
000013e0  20 74 69 6d 65 73 2c 20  69 65 2e 20 74 68 65 20  | times, ie. the |
000013f0  6c 6f 6f 70 20 69 73 20  43 3d 31 20 54 4f 20 70  |loop is C=1 TO p|
00001400  6f 77 65 72 2e 0a 0a 20  20 48 65 72 65 27 73 20  |ower...  Here's |
00001410  74 68 65 20 61 6c 67 6f  72 69 74 68 6d 2e 0a 0a  |the algorithm...|
00001420  20 20 20 53 54 41 52 54  0a 20 20 20 20 44 49 4d  |   START.    DIM|
00001430  20 58 28 23 65 78 70 65  63 74 65 64 20 64 69 67  | X(#expected dig|
00001440  69 74 73 29 0a 20 20 20  20 58 28 29 3d 30 20 20  |its).    X()=0  |
00001450  20 20 20 20 20 20 20 3b  20 73 65 74 20 61 6c 6c  |       ; set all|
00001460  20 65 6c 65 6d 65 6e 74  73 20 74 6f 20 7a 65 72  | elements to zer|
00001470  6f 0a 20 20 20 20 58 28  30 29 3d 31 20 20 20 20  |o.    X(0)=1    |
00001480  20 20 20 20 3b 20 73 65  74 20 66 69 72 73 74 20  |    ; set first |
00001490  65 6c 65 6d 65 6e 74 20  74 6f 20 31 0a 20 20 20  |element to 1.   |
000014a0  20 54 3d 30 3a 42 3d 30  20 20 20 20 20 20 20 3b  | T=0:B=0       ;|
000014b0  20 23 64 69 67 69 74 73  20 69 6e 20 61 6e 73 77  | #digits in answ|
000014c0  65 72 20 28 54 29 3d 30  0a 20 20 20 20 46 4f 52  |er (T)=0.    FOR|
000014d0  20 43 3d 31 20 54 4f 20  41 20 20 3b 20 6c 6f 6f  | C=1 TO A  ; loo|
000014e0  70 20 65 69 74 68 65 72  20 66 61 63 74 6f 72 69  |p either factori|
000014f0  61 6c 20 6f 72 20 70 6f  77 65 72 20 6e 75 6d 62  |al or power numb|
00001500  65 72 20 6f 66 20 74 69  6d 65 73 2e 0a 20 20 20  |er of times..   |
00001510  20 20 49 46 20 66 61 63  74 6f 72 69 61 6c 20 54  |  IF factorial T|
00001520  48 45 4e 0a 20 20 20 20  20 20 4b 3d 43 20 20 20  |HEN.      K=C   |
00001530  20 20 20 20 20 20 3b 20  6d 75 6c 74 69 70 6c 79  |      ; multiply|
00001540  69 6e 67 20 6e 75 6d 62  65 72 20 69 73 20 6c 6f  |ing number is lo|
00001550  6f 70 20 6e 75 6d 62 65  72 0a 20 20 20 20 20 45  |op number.     E|
00001560  4c 53 45 20 20 20 20 20  20 20 20 20 3b 20 69 74  |LSE         ; it|
00001570  20 6d 75 73 74 20 62 65  20 70 6f 77 65 72 0a 20  | must be power. |
00001580  20 20 20 20 20 4b 3d 56  20 20 20 20 20 20 20 20  |     K=V        |
00001590  20 3b 20 6d 75 6c 74 69  70 6c 79 69 6e 67 20 6e  | ; multiplying n|
000015a0  75 6d 62 65 72 20 69 73  20 61 6c 77 61 79 73 20  |umber is always |
000015b0  62 61 73 65 0a 20 20 20  20 20 45 4e 44 49 46 0a  |base.     ENDIF.|
000015c0  20 20 20 20 20 46 4f 52  20 45 3d 30 20 54 4f 20  |     FOR E=0 TO |
000015d0  54 20 20 3b 20 6c 6f 6f  70 20 23 64 69 67 69 74  |T  ; loop #digit|
000015e0  73 20 69 6e 20 61 6e 73  77 65 72 20 74 69 6d 65  |s in answer time|
000015f0  73 0a 20 20 20 20 20 20  58 28 45 29 3d 58 28 45  |s.      X(E)=X(E|
00001600  29 2a 4b 20 20 3b 20 6d  75 6c 74 69 70 6c 79 20  |)*K  ; multiply |
00001610  61 6c 6c 20 64 69 67 69  74 73 20 62 79 20 4b 0a  |all digits by K.|
00001620  20 20 20 20 20 4e 45 58  54 20 45 0a 20 20 20 20  |     NEXT E.    |
00001630  20 52 45 50 45 41 54 0a  20 20 20 20 20 20 4f 3d  | REPEAT.      O=|
00001640  54 0a 20 20 20 20 20 20  46 4f 52 20 45 3d 42 20  |T.      FOR E=B |
00001650  54 4f 20 54 0a 20 20 20  20 20 20 20 49 46 20 58  |TO T.       IF X|
00001660  28 45 29 3e 39 20 50 52  4f 43 78 20 20 20 3b 20  |(E)>9 PROCx   ; |
00001670  63 68 65 63 6b 20 66 6f  72 20 27 64 69 67 69 74  |check for 'digit|
00001680  27 3e 3d 31 30 20 61 6e  64 20 63 61 72 72 79 20  |'>=10 and carry |
00001690  69 66 20 73 6f 0a 20 20  20 20 20 20 4e 45 58 54  |if so.      NEXT|
000016a0  20 45 20 20 20 20 20 20  20 20 20 20 20 20 20 0a  | E             .|
000016b0  20 20 20 20 20 55 4e 54  49 4c 20 4f 3e 3d 54 20  |     UNTIL O>=T |
000016c0  20 20 20 20 20 20 20 20  20 3b 20 66 6f 72 20 61  |         ; for a|
000016d0  6c 6c 20 27 64 69 67 69  74 73 27 20 63 75 72 72  |ll 'digits' curr|
000016e0  65 6e 74 6c 79 20 69 6e  20 61 6e 73 77 65 72 0a  |ently in answer.|
000016f0  20 20 20 20 20 42 3d 30  0a 20 20 20 20 4e 45 58  |     B=0.    NEX|
00001700  54 20 43 20 3b 20 6c 6f  6f 70 0a 20 20 20 45 4e  |T C ; loop.   EN|
00001710  44 0a 20 20 20 20 3a 0a  20 20 20 20 44 45 46 20  |D.    :.    DEF |
00001720  50 52 4f 43 78 20 20 20  20 20 20 20 20 20 20 20  |PROCx           |
00001730  20 20 3b 20 50 52 4f 43  65 64 75 72 65 20 74 6f  |  ; PROCedure to|
00001740  20 73 6f 72 74 20 6f 75  74 20 63 61 72 72 79 0a  | sort out carry.|
00001750  20 20 20 20 20 48 3d 49  4e 54 28 58 28 45 29 2f  |     H=INT(X(E)/|
00001760  31 30 29 20 20 20 20 20  20 20 3b 20 66 69 72 73  |10)       ; firs|
00001770  74 20 64 65 74 65 72 6d  69 6e 65 20 6e 75 6d 62  |t determine numb|
00001780  65 72 20 6f 66 20 74 65  6e 73 0a 20 20 20 20 20  |er of tens.     |
00001790  49 46 20 48 3e 28 58 28  45 29 2f 31 30 29 3a 48  |IF H>(X(E)/10):H|
000017a0  3d 48 2d 31 20 0a 20 20  20 20 20 58 28 45 2b 31  |=H-1 .     X(E+1|
000017b0  29 3d 58 28 45 2b 31 29  2b 48 20 20 20 20 20 20  |)=X(E+1)+H      |
000017c0  3b 20 74 68 65 6e 20 61  64 64 20 74 65 6e 73 20  |; then add tens |
000017d0  74 6f 20 6e 65 78 74 20  64 69 67 69 74 0a 20 20  |to next digit.  |
000017e0  20 20 20 58 28 45 29 3d  58 28 45 29 2d 28 48 2a  |   X(E)=X(E)-(H*|
000017f0  31 30 29 20 20 20 20 20  3b 20 6e 65 78 74 20 73  |10)     ; next s|
00001800  75 62 74 72 61 63 74 20  66 72 6f 6d 20 63 75 72  |ubtract from cur|
00001810  72 65 6e 74 20 64 69 67  69 74 0a 20 20 20 20 20  |rent digit.     |
00001820  49 46 20 28 45 2b 31 29  3e 54 20 54 3d 45 2b 31  |IF (E+1)>T T=E+1|
00001830  3a 42 3d 54 20 3b 20 6e  6f 77 20 65 78 74 65 6e  |:B=T ; now exten|
00001840  64 20 74 68 65 20 6e 75  6d 62 65 72 20 6f 66 20  |d the number of |
00001850  64 69 67 69 74 73 20 69  6e 20 61 6e 73 77 65 72  |digits in answer|
00001860  20 28 54 29 20 69 66 20  6e 65 63 65 73 73 61 72  | (T) if necessar|
00001870  79 2e 0a 20 20 20 20 45  4e 44 50 52 4f 43 0a 20  |y..    ENDPROC. |
00001880  20 20 20 3a 0a 0a 20 20  49 74 27 73 20 77 6f 72  |   :..  It's wor|
00001890  74 68 20 6d 65 6e 74 69  6f 6e 69 6e 67 20 74 68  |th mentioning th|
000018a0  61 74 20 49 20 6d 61 64  65 20 74 68 69 73 20 6d  |at I made this m|
000018b0  79 73 65 6c 66 2c 20 62  79 20 74 68 65 20 6d 65  |yself, by the me|
000018c0  74 68 6f 64 20 77 68 69  63 68 20 73 65 65 6d 65  |thod which seeme|
000018d0  64 20 6d 6f 73 74 20 73  65 6e 73 69 62 6c 65 20  |d most sensible |
000018e0  74 6f 20 6d 65 2e 20 49  74 27 73 20 65 6e 74 69  |to me. It's enti|
000018f0  72 65 6c 79 20 70 6f 73  73 69 62 6c 65 20 74 68  |rely possible th|
00001900  61 74 20 0a 74 68 65 72  65 27 73 20 61 20 62 65  |at .there's a be|
00001910  74 74 65 72 20 6d 65 74  68 6f 64 20 66 6f 72 20  |tter method for |
00001920  77 6f 72 6b 69 6e 67 20  74 68 65 73 65 20 74 68  |working these th|
00001930  69 6e 67 73 20 6f 75 74  2c 20 62 75 74 20 6d 79  |ings out, but my|
00001940  20 77 61 79 20 77 6f 72  6b 73 20 73 6f 20 49 27  | way works so I'|
00001950  6d 20 68 61 70 70 79 2e  0a 0a 0a 0a 2a 2a 2a 2a  |m happy.....****|
00001960  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
000019d0  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 0a 0a 20  |*************.. |
000019e0  49 66 20 61 6e 79 6f 6e  65 20 6e 65 65 64 73 20  |If anyone needs |
000019f0  74 6f 20 63 6f 6e 74 61  63 74 20 6d 65 20 74 68  |to contact me th|
00001a00  65 20 73 61 66 65 73 74  20 62 65 74 20 69 73 20  |e safest bet is |
00001a10  6d 79 20 68 6f 6d 65 20  61 64 64 72 65 73 73 3b  |my home address;|
00001a20  0a 0a 20 20 20 20 20 20  20 37 20 52 69 76 65 72  |..       7 River|
00001a30  73 64 65 6e 65 2c 0a 20  20 20 20 20 20 20 20 53  |sdene,.        S|
00001a40  74 6f 6b 65 73 6c 65 79  2c 0a 20 20 20 20 20 20  |tokesley,.      |
00001a50  20 20 43 6c 65 76 65 6c  61 6e 64 2e 0a 20 20 20  |  Cleveland..   |
00001a60  20 20 20 20 20 54 53 39  20 35 44 44 2e 0a 0a 20  |     TS9 5DD... |
00001a70  4f 72 2c 20 69 66 20 69  74 27 73 20 64 75 72 69  |Or, if it's duri|
00001a80  6e 67 20 74 65 72 6d 20  74 69 6d 65 2c 20 49 20  |ng term time, I |
00001a90  63 61 6e 20 62 65 20 63  6f 6e 74 61 63 74 65 64  |can be contacted|
00001aa0  20 62 79 20 73 28 6e 61  69 6c 29 2d 6d 61 69 6c  | by s(nail)-mail|
00001ab0  20 61 74 3b 0a 0a 20 20  20 20 20 20 20 48 75 6c  | at;..       Hul|
00001ac0  6d 65 20 48 61 6c 6c 2c  0a 20 20 20 20 20 20 20  |me Hall,.       |
00001ad0  20 4f 78 66 6f 72 64 20  50 6c 61 63 65 2c 0a 20  | Oxford Place,. |
00001ae0  20 20 20 20 20 20 20 56  69 63 74 6f 72 69 61 20  |       Victoria |
00001af0  50 61 72 6b 2c 0a 20 20  20 20 20 20 20 20 4d 61  |Park,.        Ma|
00001b00  6e 63 68 65 73 74 65 72  2e 0a 20 20 20 20 20 20  |nchester..      |
00001b10  20 20 4d 31 34 20 35 52  52 2e 0a 0a 20 20 20 20  |  M14 5RR...    |
00001b20  20 61 6e 64 20 62 79 20  65 28 61 73 79 29 2d 6d  | and by e(asy)-m|
00001b30  61 69 6c 20 61 74 3b 0a  0a 20 20 20 20 20 20 20  |ail at;..       |
00001b40  41 4a 4d 40 66 73 31 2e  6d 61 2e 75 6d 69 73 74  |AJM@fs1.ma.umist|
00001b50  2e 61 63 2e 75 6b 0a 0a  0a 20 20 20 20 20 20 20  |.ac.uk...       |
00001b60  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00001b90  20 20 20 20 20 20 20 20  20 20 20 20 20 20 41 6e  |              An|
00001ba0  64 72 65 77 20 4a 20 4d  61 72 6b 77 69 63 6b 20  |drew J Markwick |
00001bb0  20 20 37 2f 31 30 2f 39  34 20 20 31 3a 33 33 61  |  7/10/94  1:33a|
00001bc0  6d 2e 0a 0a 0a 0a                                 |m.....|
00001bc6