
-----------------------------------
lapo3399
Sat Feb 26, 2005 10:09 pm

Sequences and Series
-----------------------------------
For any of you who have had to do sequences and seriesor needs help with them.
Here is a program I have made to find any term of an arithmetic/geometric sequence, the sum of any arithmetic or geometric series, the r value for a geometric sequence or the d value for an arithmetic sequence. It also tells you the equation for the term of a sequence.


% Sequence and Series Utility
% Copyright Matt Laporte 2005
var count : int
var t1, t2, t3, d, r, n, sum, term, tn : real
var answers, answert, answerntn, answeraa, answerfin : string
procedure termfindgeo
    put "Thank you. Would you like to find a term in this sequence?"
    get answert
    if answert = "yes" then
        put "Enter the n value."
        get n
        term := t1 * (r ** (n - 1))
        put "The term is ", term, "."
    elsif answert = "no" then
        put "Thank you for using SaSU! Any comments or questions can be sent to lapo3399@gmail.com."
    end if
end termfindgeo
procedure termfindarith
    put "Thank you. Would you like to find a term/term number in this sequence?"
    get answert
    if answert = "yes" then
        put "Do you have the n or the tn value? (enter n or tn)"
        get answeraa
        if answeraa = "n" then
            put "What is the n value?"
            get n
            term := t1 + ((n - 1) * d)
            put "The term is ", term, "."
        elsif answeraa = "tn" then
            put "What is the tn value?"
            get tn
            n := (tn / d) - (t1 / d) + 1
            put "The term number is ", n, "."
        end if
    elsif answert = "no" then
        put "Thank you for using SaSU! Any comments or questions can be sent to lapo3399@gmail.com."
    end if
end termfindarith
loop
    var fontID := Font.New ("comic sans ms:12")
    Font.Draw ("Copyright Matt Laporte 2005", 225, 5, fontID, 7)
    put "Welcome to SaSU"
    put "This program will determine the type and values for d or r for any sequence."
    put "It will also determine the sum of a series if asked."
    put "Enter the first 3 terms of the sequence."
    put "Term 1 ="
    get t1
    put "Term 2 ="
    get t2
    put "Term 3 ="
    get t3
    if t3 / t2 = t2 / t1 then
        r := t3 / t2
        put "The sequence is geometric, and the r value is ", r, "."
        put "The a value is ", t1, ". The formula for this geometric sequence is tn=", t1, "(", r, ")**n-1"
        put "Would you like to find the sum of a series represented by this sequence?"
        get answers
        if answers = "yes" then
            put "Enter the n value:"
            get n
            sum := (t1 * ((r ** n) - 1)) / (r - 1)
            put "The sum of the geometric series is ", sum, "."
            termfindgeo
        elsif answers = "no" then
            termfindgeo
        end if
    elsif t3 - t2 = t2 - t1 then
        d := t3 - t2
        put "The sequence is arithmetic, and the d value is ", d, "."
        put "The a value is ", t1, ". The formula for the arithmetic sequence is tn=", t1, "+(n-1)", d, "."
        put "Would you like to find the sum of a series represented by this sequence?"
        get answers
        if answers = "yes" then
            put "Do you have the n or the tn value? (enter n or tn)"
            get answerntn
            if answerntn = "n" then
                put "What is the n value?"
                get n
                sum := (n / 2) * ((2 * t1) + ((n - 1) * d))
                put "The sum of the arithmetic series is ", sum, "."
                termfindarith
            elsif answerntn = "tn" then
                put "What is the tn value?"
                get tn
                sum := ((-t1 + d + tn) / (2 * d)) * (tn + t1)     %This equation I actually developed in my math class :)
                put "The sum of the arithmetic series is ", sum, "."
                termfindarith
            end if
        elsif answers = "no" then
            termfindarith
        end if
    elsif t3 - t2 not= t2 - t1 and t3 / t2 not= t2 / t1 then
        put "This sequence is not arithmetic or geometric. It may be a combination of both,  or neither."
    end if
    put "Would you like to run SaSU again?"
    get answerfin
    if answerfin = "no" then
        quit
    elsif answerfin = "yes" then
        cls
    end if
end loop


plz post comments or suggestions as I am not that experienced and can always learn
 :D thnx

-----------------------------------
jamonathin
Sun Feb 27, 2005 6:24 pm


-----------------------------------
Pretty good program. You should just either cls or put .. after the put statements so your "copyright" oesn't   get overwritten.
ex.

put "Thank you for using SaSU! Any comments or questions can be sent to lapo3399@gmail.com." ..


-----------------------------------
ssr
Sun Feb 27, 2005 7:33 pm


-----------------------------------
u should change the quit into exit 
adn put ..behaind the "Term 1 ="

but nice program 8)

-----------------------------------
lapo3399
Sun Feb 27, 2005 8:04 pm


-----------------------------------
Ty....
I noticed the cls problem right after I posted.. Thnx neway help is always appreciated.
 :)
