1) Write a function exp, which returns x to the power of n, using iteration.
2) Write a function exp2, which returns x to the power of n, using recursion.
3) http://en.wikipedia.org/wiki/Pascal's_triangle
n is the row, k is the column.
P(0, 0) is 1
P(1,0) is 1
P(1,1) is 1
P(2,0) is 1
P(2,1) is 2, because it is P(1,0)+P(1,1)
P(2,2) is 1
Write P, recursively
4) Write a function max, which takes in x and y and returns whichever is bigger, by comparing each *digit* in turn. Do this using iteration. Do this using recursion.
Wednesday, April 14, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment