about | help | code help+videos | done | prefs |
Without using recursion, and without using the Math library, write a method that uses a loop to calculate the result of taking 'base' to the 'power'. For example, if 'base' is 5 and 'power' is 3 the result would be 125 because 5 to the third power is 125. As preconditions, you may assume that base and power will both be non-negative. Please note that these results can get very large, so 'int' is not big enough to store your result. Use 'long' instead. This is just like 'int' except that it can store larger numbers. Remember: Do NOT use recursion nor the Math class. exponent(7, 12) → 13841287201 exponent(10, 15) → 1000000000000000 exponent(0, 8) → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 220
Copyright Nick Parlante 2017 - privacy