1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
defon
2 years ago
11

Implement a sublinear running time complexity recursive function in Java public static long exponentiation (long x, int n) to ca

lculate x^n. Note: In your function you can use only the basic arithmetic operators (+, -, *, and /).
Computers and Technology
1 answer:
Charra [1.4K]2 years ago
4 0

Answer:

Following are the code block in the Java Programming Language.

//define recursive function

public static long exponentiation(long x, int n) {

//check the integer variable is equal to the 0.

if (x == 0) {

//then, return 1

return 1;

}

//Otherwise, set else

else {

//set long data type variable

long q = exponentiation(x, n/2);

q *= q;

//check if the remainder is 1

if (n % 2 == 1) {

q *= x;

}

//return the variable

return q;

}

}

Explanation:

<u>Following are the description of the code block</u>.

  • Firstly, we define the long data type recursive function.
  • Then, set the if conditional statement and return the value 1.
  • Otherwise, set the long data type variable 'q' that sore the output of the recursive function.
  • Set the if conditional statement and check that the remainder is 1 and return the variable 'q'.
You might be interested in
Would you rather be rich and unknown or famous and poor
ollegr [7]

Answer:

rich g

Explanation:

5 0
2 years ago
Imagine a typical website that works as a storefront for a business, allowing customers to browse goods online, place orders, re
Gwar [14]

Answer: See explanation

Explanation:

Following the information given in the question, the testing process for the website will include testing the links that are on the site.

Another that ng to test is to check if the menus and the buttons are working properly. Furthermore, the layout should be ensured that it's consistent as well as the ease with which the website can be used.

5 0
3 years ago
What is the distance from the end of the pin to the center of the hole?
Lemur [1.5K]

Answer:

Roughly 7/8 on the pinhole, roughly 2-1/4" from the pinhole to end of the adapter.

Explanation:

8 0
1 year ago
In Python, if var1 = "Happy" and var2= "Birthday" and var3 = (var 1+var2) *2, then var3 stores the string
nordsb [41]

Answer:

The answer is "Option A".

Explanation:

The program to the given question can be given as:

program:

var1 = "Happy" #defining variable var1

var2= "Birthday" #defining variable var2

var3 = (var1+var2) *2 #defining variable var3 and calculate value

print (var3) #print value.

Output:

HappyBirthdayHappyBirthday

In the above python program, three variable is defined, that is var1, var2, and var3, in which variable var1 and var2 we assign a value, that is "Happy" and "Birthday".

In variable var3 we add the value of var1 and var2 variable and multiply by 2. It will print the variable value two times. and other options are not correct that can be defined as:

  • In option B and C, Both variable var1 and var2 print there values two times but in option B var1 value print two time and var2 value print one time only and option C var1 variable value is print only one time and var2 variable value is print two times that's why it is not correct.
  • In option C, Both variable var1 and var2 print there values two times that's why it is not correct.

7 0
2 years ago
When companies charge different prices for the same product, they're using
Maksim231197 [3]

Answer: When companies charge different

prices for the same product, they're using

B.) Dynamic Pricing

Is the most accurate

Explanation: If a firm can find a way to charge every customer the price he/she values a good at, the firm can capture more profits than it could with a single price, in a given market.

7 0
1 year ago
Other questions:
  • The set of specific, sequential steps that describe exactly what a computer program must do to complete the work is called a(n _
    14·1 answer
  • One metric ton is approximately 2,205 pounds.
    6·1 answer
  • What are the data types used in C programming with examples
    5·1 answer
  • Describe some ways that you personally use information technologies differently than you did just a few years ago
    11·1 answer
  • I’m trying to get answers from Brainly and it’s not showing up. I’ve been refreshing the browser, but it’s the same. I’ve never
    10·2 answers
  • PrimeFactorization.java: Write a program that begins by reading in a series of positive integers on a single line of input and t
    12·1 answer
  • Evolucion de los sistemas operativos
    5·1 answer
  • Have all of my coins because i will delete acount there will be part 2, 3 , 4 ,5,6,7,8
    15·2 answers
  • How are mathematics and computer science similar? Discuss any connections between numbers, logic, and other elements.
    14·1 answer
  • Do network packets take the shortest route?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!