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
Nata [24]
3 years ago
9

Write a recursive function is_pow2(n) that returns True if the positive integer n is an integer power of 2, and False otherwise.

For example: function call return value is_pow2(1) True is_pow2(2) True is_pow2(3) False is_pow2(4) True is_pow2(5) False is_pow2(6) False is_pow2(7) False is_pow2(8) True is_pow2(9) False is_pow2(255) False is_pow2(256) True Hint: Consider using repeated floor division.
Computers and Technology
1 answer:
bezimeni [28]3 years ago
8 0

Answer:

In Python:

def is_power(n):

   if n > 2:

       n = n/2

       return is_power(n)

   elif n == 2:

       return True

   else:

       return False

Explanation:

This defines the function

def is_power(n):

If n is greater than 0

   if n > 2:

Divide n by 2

       n = n/2

Call the function

       return is_power(n)

If n equals 2

   elif n == 2:

Return True

       return True

If n is less than 2

   else:

Then, return false

       return False

You might be interested in
What refers to the use of technology to create product styles and designs?
torisob [31]
The answer is graphic design
8 0
3 years ago
PLSSS HELLLP!!! THE CROWN WILL BE REWARDED FOR THE CORRECT ANSWER!!!
Sergio039 [100]

Answer:

The audience

Explanation:

The correct option is - The audience

Reason -

When writing a technical document -

Always describe things in technical terms.

Write for your readers.

Describe things exactly as they're described to you by subject matter experts.

Technical writing :

Addresses particular readers.

Helps readers solve problems.

4 0
3 years ago
The ____________ protocol enables two users to establish a secret key using a public-key scheme based on discrete logarithms
strojnjashka [21]

The answer in the space provided is the Diffie-Hellman Key Exchange. This is entitled to be the first published key algorithm in which has a limit in which the exchange occurs in secret values and that its purpose was to enable two users to have an exchange of key in a secure manner in means of using it for a subsequent symmetric encryption in terms of messages.

7 0
3 years ago
What are three different reasons why people access networks? <br> Give an example of each reason
denpristay [2]

Communication: Communication is one way to be connected to the network and use the internet. It helps maintains communication with other network users. A few examples include email, IM services, video conferencing, Skype and many more.

File sharing: Easily sharing files and data. From businesses to schools to friends, everyone sends files to through internet and this has become an essential part of life. Various services like Gmail and yahoo mail are used.

Social networking: This is an essential medium to communicate with friends and family members. Examples include Facebook, Twitter, and Instagram.






3 0
3 years ago
How is hashing used?
Aliun [14]

Answer: Its A. used to protect the transmission of software and large files to be downloaded

Explanation: Hashing is an algorithm that calculates a fixed-size bit string value from a file. A file basically contains blocks of data. Hashing transforms this data into a far shorter fixed-length value or key which represents the original string. The hash value can be considered the distilled summary of everything within that file. A good hashing algorithm would exhibit a property called the avalanche effect, where the resulting hash output would change significantly or entirely even when a single bit o...

3 0
3 years ago
Other questions:
  • Is a type of bullying that takes place when a person intentionally posts negative information about another that is not true
    8·1 answer
  • Net Worth is equal to assets minus liabilities. Which event will have the greatest impact (positive or negative) on one's net wo
    9·1 answer
  • Whats the relationship between the CPU and motherboard
    6·1 answer
  • Why are duplicate tuples not allowed in a relation?
    6·1 answer
  • Create and test a user-defined function named ufnFullName that combines the values of the two parameters named FirstName and Las
    15·1 answer
  • Who benefits from digital technology?
    15·1 answer
  • Npesta kenos reaction
    13·2 answers
  • Before her shift as a cashier at the grocery store, Carla pulls her hair back into a ponytail and makes sure her fingernails are
    11·1 answer
  • How can i setup a mesage room and also want to hangout ??????
    10·1 answer
  • _____ refers to the programs that a device can run.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!