Results 1 to 2 of 2

Math Help - Recursive algorithm

  1. #1
    Newbie
    Joined
    Nov 2008
    Posts
    11

    Recursive algorithm

    Devise a recursive algorithm to find a^(2^n) n where a is a real number and n
    is a positive integer.

    This is a bit tricky
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by dh214 View Post
    Devise a recursive algorithm to find a^(2^n) n where a is a real number and n
    is a positive integer.

    This is a bit tricky
    Only for small values of tricky.

    a^{2^n}=(a^{2^{n-1}})^2

    so:

    Code:
    function aToThe2n(a,n)
      if n==1
         rv=a^2
      else
        rv=(aToThe2n(a,n-1))^2
      endif
    
      return rv
    endfunction
    CB
    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, 10:22 AM
  2. Recursive Algorithm
    Posted in the Discrete Math Forum
    Replies: 4
    Last Post: January 6th 2009, 01:55 AM
  3. Recursive algorithm
    Posted in the Discrete Math Forum
    Replies: 6
    Last Post: November 10th 2008, 10:44 PM
  4. Recursive Algorithm
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: November 9th 2008, 10:56 PM
  5. Recursive algorithm
    Posted in the Discrete Math Forum
    Replies: 7
    Last Post: May 21st 2007, 03:15 PM

Search Tags


/mathhelpforum @mathhelpforum