Results 1 to 2 of 2

Math Help - Recursive algorithm

  1. #1
    Newbie
    Joined
    Oct 2009
    Posts
    3

    Recursive algorithm

    Give a recursive algorithm for computing n * a using only addition, where n is a positive integer and a is a real number. Hint: add a to itself n times.
    Last edited by mr fantastic; October 17th 2009 at 03:04 PM. Reason: Changed post title
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member Matt Westwood's Avatar
    Joined
    Jul 2008
    From
    Reading, UK
    Posts
    824
    Thanks
    33
    Quote Originally Posted by zap1231 View Post
    Give a recursive algorithm for computing n * a using only addition, where n is a positive integer and a is a real number. Hint: add a to itself n times.
    This is the standard one:

    n \times a = \begin {cases} 0 & : n = 0 \\ (n-1) \times a + a & : n \ne 0 \end{cases}

    Or if 0 is not considered a positive integer, start with na = 1 when n = 1.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. recursive algorithm
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: November 23rd 2009, 11:22 AM
  2. Recursive Algorithm
    Posted in the Discrete Math Forum
    Replies: 4
    Last Post: January 6th 2009, 02:55 AM
  3. Recursive Algorithm
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: November 9th 2008, 11:56 PM
  4. Recursive algorithm
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: November 6th 2008, 05:50 AM
  5. Recursive algorithm
    Posted in the Discrete Math Forum
    Replies: 7
    Last Post: May 21st 2007, 04:15 PM

Search Tags


/mathhelpforum @mathhelpforum