Given a real positive number a and a nonnegative integer n .
Calculate a^n without using cycles and the function math.pow() , but using the recurrence relation a^n=a*a^(n-1) .
Given a real positive number a and a nonnegative integer n .
Calculate a^n without using cycles and the function math.pow() , but using the recurrence relation a^n=a*a^(n-1) .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
private double pow(double a, int n) { if (n == 0) { return 1; } return pow(a, n-1)*a; } But do not forget about the range of values ​​for double .
pow ! - AK ♦Math.pow(...) method? - post_zeewSource: https://ru.stackoverflow.com/questions/607833/
All Articles