about | help | code help+videos | done | prefs |
Write a function power(base, exponent) that returns the value base^exponent, i.e. base * base * base * ... * base, where there are exponent many terms of the product. For example, powerLoop(2,5) = 2^5 = 32 because 2*2*2*2*2 = 32. Do not use the operator **. Instead, use an accumulator and a for loop that runs n times. powerLoop(2, 3) → 8 powerLoop(4, 0) → 1 powerLoop(3, 3) → 27 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy