[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1252.0. "Backdoor Factorial Needed" by DEC25::ROBERTS (Reason, Purpose, Self-esteem) Tue Jun 12 1990 16:57

T.RTitleUserPersonal
Name
DateLines
1252.1HPSTEK::XIAIn my beginning is my end.Tue Jun 12 1990 17:074
    If your A2 is very large, you could use the Sterling (sp?) formula.
    Otherwise, you will just have to use * .
    
    Eugene
1252.2GUESS::DERAMOColorado Rocky Mountain highTue Jun 12 1990 17:184
	What is available in the way of if-then-else, recursion,
	and iteration?

	Dan
1252.3More RE 2020DEC25::ROBERTSReason, Purpose, Self-esteemTue Jun 12 1990 21:5150
    2020 doesn't care too much for recursion; it thinks there are circular
    references.
    
    Iteration can be achieved in a couple of ways.
    
    The first is through "goal seeking," a process of automatically
    modifying one cell, recalculating all other cells, to reach a target.
    For example, if the cells were initialized as:
    
    A1: 1.00
    A2: (A1)^3-5*(A1)^2+8*(A1)-12
    
    it would continue to modify A1 until it was 3.71618865899311 and the
    value of A2 was 0.0000000000. I don't know what algorithm it uses to
    determine how to adjust A1 each time.
    
    Iteration can also be performed by use of macros, too. The following
    macro calculates a factorial. The topmost row and leftmost column are
    not part of the macro; they're column and row identifiers. The macro is
    executed by telling the spreadsheet to execute D0. The first macro
    command, "#QUIET," just tells it not to display intermediate
    calculations.
    

         A       B       C       D
   
   
 0       6     720        #QUIET
 1                        #LET([D11]=[A0])
 2                        #LET([B0]=1)
 3                        #LABEL(FACTLOOP)
 4                        #IF([D11]>1)
 5                        #THEN
 6                        #LET([B0]=[B0]*[D11])
 7                        #DECR([D11])
 8                        #BRANCH(FACTLOOP)
 9                        #ENDIF
10                        #RETURN
11                               1
    
    This is a primitive macro. It "blows up" when the initial value (A0) is
    greater than 33. It's not position-independent code; that is, it will
    only calculate the factorial for the value in A0, it will always put it
    in B0, and the macro itself must live in D0..D11.
    
    My hope was to not have to use a macro. Unfortunately, I don't think
    there's any other way.
    
    /Dwayne
    
1252.4GUESS::DERAMOColorado Rocky Mountain highWed Jun 13 1990 03:025
        Perhaps he can initialize a row or column of a
        spreadsheet to the proper values (up to where they
        overflow), and import the correct cell when he needs it.
        
        Dan