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]
2 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]2 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 is the CPI of the central processing unit cpu of a computer
vlada-n [284]
Electronic component on a computer's
motherboard that interprets and carries
out the basic instructions that operate
the computer; also called processor.
5 0
2 years ago
Under which tab can you find the options for reusing slides from other presentations
MrRissso [65]
U could first highlight text, right click then copy, and then Ctrl + v. You could find Ctrl (or control) under the shift button to your left
I hope this helped:D
5 0
3 years ago
Write a simple Html structure and explain the meaning of each line
seropon [69]

Answer:

HTML stands for HyperText Markup Language and is the basic structural element that is used to create webpages. HTML is a markup language, which means that it is used to “mark up” the content within a document, in this case a webpage, with structural and semantic information that tells a browser how to display a page. When an HTML document is loaded by a web browser, the browser uses the HTML tags that have marked up the document to render the page’s content.

There are three types of code that make up a basic website page. HTML governs the structural elements, CSS styles those elements, and JavaScript enables dynamic interaction between those elements.

7 0
2 years ago
During an election year, why would a senator want to determine a mode?
ale4655 [162]

Answer:

To determine which issue is most important to the general public.

Explanation:

Took the Edge assignment!

3 0
2 years ago
Suppose a switch is built using a computer work station and that it can forward packets at a rate of 500,000 packets per second,
Marina86 [1]

Answer:

When the transmission exceeds 667 packets

Explanation:

In computer networking, a packet is a chunk of data transmitted across the network. The packet size of an Ethernet network is 1.5kilobytes, while the packet size of an IP packet payload is 64 kilobytes.

A switch is a physical network device that connects nodes or workstations while communicating the packets (or frames). The I/O bus size bandwidth is 1Gbps which allows approximately 667 packets. Once this packet size is crossed, the bus becomes a limiting factor or bottle neck.

3 0
3 years ago
Other questions:
  • you are a software engineering consultant and have been called in by the vice president of finance of a corporation that manufac
    10·1 answer
  • What two terms below describe a network device with three ports, two of which send and receive all traffic, and the third port m
    6·1 answer
  • When you send an echo request message with the ping program, a successful attempt will return a(n) ______ message.
    8·1 answer
  • Alejandra is using a flash drive that a friend gave to her to copy some financial records from the company database so she can c
    12·1 answer
  • what is it called when you are biying and selling products via electronic channels such as the internet​
    13·2 answers
  • Which of the following function declarations correctly expect an array as the first argument?
    12·1 answer
  • Why did latex replace wax?
    7·1 answer
  • Examples of domain names and usernames<br><br><br><br>​
    11·1 answer
  • Nicole is in a study group to prepare for a test on plant biology, a subject she knows a lot about. During their meetings, she a
    8·2 answers
  • What do you mean by computer ethics?​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!