Results 1 to 1 of 1

Math Help - Mathematical Logic Algorithm

  1. #1
    Junior Member
    Joined
    Feb 2009
    Posts
    33

    Mathematical Logic Algorithm

    I need to write an algorithm with appropriate assertions and input and output specifications that gives the sum of n given numbers. Then I need to prove it. This is what I have, is it right?

    Input:  n_{1},n_{2},...,n_{m}
    Output: s
    Algorithm SUM
              \{n_{1},n_{2},...,n_{m} integers , -\infty < n_{1},...,n_{m} < \infty \}
             s \leftarrow 0; i \leftarrow 0
    Loop Invariant: \{s=s+n_{i}, i=1,2,...,m \}
    Repeat until: i=m
    s \leftarrow s + n_{i}
     i \leftarrow i + 1
    End repeat
    Loop termination condition: \{s=s+n_{i} \wedge i=m \}
    Output specification: \{s= n_{1},n_{2},...,n_{m}\}
    Last edited by VENI; April 7th 2009 at 07:38 PM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. What does N.T.A mean in mathematical logic?
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: June 1st 2010, 11:54 AM
  2. derive formulas in mathematical logic
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: March 4th 2010, 02:25 AM
  3. mathematical logic books
    Posted in the Discrete Math Forum
    Replies: 4
    Last Post: August 9th 2009, 10:03 AM
  4. Replies: 3
    Last Post: July 17th 2009, 10:10 AM
  5. heapsort algorithm logic sets
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: February 19th 2009, 02:20 AM

Search Tags


/mathhelpforum @mathhelpforum