subject
Mathematics, 30.09.2019 22:20 ghernadez

The following recursive method calculates 3n : // precondition: n > = 0 public int power3(int n) { if (n == 0) // if n equals to 0 return 1; else { int p = power3(n/2); // when n is odd, n/2 is truncated to an integer // e. g., 7/2 gives 3 and 1/2 gives 0 p *= p; // multiply p by itself if (n % 2 == 1) // if n is odd p *= 3; // multiply p by 3 return p; } } how many multiplications will be performed when the program calls power3(15)?

ansver
Answers: 3

Another question on Mathematics

question
Mathematics, 21.06.2019 18:00
Use the distributive law to multiply. 3(4x + 5y + 6)
Answers: 2
question
Mathematics, 22.06.2019 00:30
What is the solution of the equation? 35√(x+2)3+3=27
Answers: 1
question
Mathematics, 22.06.2019 01:00
Azul has 4 green picks and no orange picks.you add orange picks so that there are 2 orange picks for every 1 green pick.how many picks are there now.
Answers: 2
question
Mathematics, 22.06.2019 04:20
Michael gose to a theme park and rides two different roller coasters that both begin on a raised platform his height while on the first roller coaster measured in feet from the platform height can be modeled by the following graph where t is the number of seconds since the ride began
Answers: 2
You know the right answer?
The following recursive method calculates 3n : // precondition: n > = 0 public int power3(int n...
Questions
question
Chemistry, 15.10.2020 09:01
question
English, 15.10.2020 09:01
Questions on the website: 13722366