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; Oct 17th 2009 at 02:04 PM.
Reason: Changed post title
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:
Or if 0 is not considered a positive integer, start with na = 1 when n = 1.