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
yKpoI14uk [10]
3 years ago
15

Write a recursive function next_pow2(n) that returns the smallest integer value p such that for a non-negative value n. For exam

ple: function call return value next_pow2(0) 0 next_pow2(1) 0 next_pow2(2) 1 next_pow2(3) 2 next_pow2(4) 2 next_pow2(5) 3 next_pow2(6) 3 next_pow2(7) 3 next_pow2(8) 3 next_pow2(9) 4 next_pow2(255) 8 next_pow2(256) 8 next_pow2(257) 9
Computers and Technology
1 answer:
Finger [1]3 years ago
8 0

Answer:

Explanation:

The following code is written in Python and is a recursive function as requested that uses the current value of p (which is count in this instance) and raises 2 to the power of p. If the result is greater than or equal to the value of n then it returns the value of p (count) otherwise it raises it by 1 and calls the function again.

def next_pow2(n, count = 0):

   if (2**count) < n:

       count += 1

       return next_pow2(n, count)

   else:

       return count

You might be interested in
Compare and contrast system software and generalised software
jekas [21]
System software is a type of computer program that is designed to run a computer’s hardware and application programs.
Generalized software refers to software designed to read, process and write data with the help of functions performing specific audit routines and with self-made macros.
3 0
4 years ago
Ashley Baker has been the webmaster for Berryhill Finance only ten days when she received an e-mail that threatened to shut down
Natasha_Volkova [10]

Answer:

cyber-extortion

Explanation:

Ashley Baker has been the webmaster for Berryhill Finance only ten days when she received an e-mail that threatened to shut down Berryhill's website unless Ashley wired payment to an overseas account. Ashley was concerned that Berryhill Finance would suffer huge losses if its website went down, so she wired money to the appropriate account. The author of the e-mail successfully committed cyber-extortion.

7 0
3 years ago
What is cryptocurrency ? I need to do a research one it please help!
icang [17]

A cryptocurrency is a digital asset designed to work as a medium of exchange that uses strong cryptography to secure financial transactions, control the creation of additional units, and verify the transfer of assets.

8 0
3 years ago
Both successors to C++, _____ , by Sun Microsystems, and _______, by rival MicroSoft, are very similar.
Tanzania [10]

Answer: Java and Forth

Explanation:

   C ++ and Java are comparatively similar language which are composed statically, unequivocally, and obviously. Both language are the object-oriented and planned with the semi-interpretation and run-time during the compilation of the time.

Both uses the curly braces and also they are very similar language as compared with c# and c. Both the successors in the C++ , java and sun micro-system are similar in terms of Microsoft.

 

8 0
3 years ago
Which types of files are saved with the .Mp3 and .Zip extensions? Files are saved with the .Mp3 extension and files are saved wi
maw [93]

Answer:

Audio files have the ".mp3" file extension and compressed files have the ".zip" file extension.

Explanation:

6 0
3 years ago
Other questions:
  • Suppose you send data to the 11111111 11111111 11111111 11111111 ip address on an ipv4 network. to which device(s) are you trans
    15·1 answer
  • âwhat two log files are used by older versions of unix and newer version of linux to store log information
    10·2 answers
  • Which command on the Insert tab of the PowerPoint Online application is used to add a Venn diagram or process chart to a present
    12·2 answers
  • What is the use of pecil icon
    11·2 answers
  • Which statement is true?
    5·2 answers
  • Which of the following software maintenance steps erases gaps caused by deleting files from the hard drive?
    10·1 answer
  • The Apple iPhone was a revolutionary product when it was introduced in 2007. To what extent do you agree or disagree with this s
    8·1 answer
  • E-mail messages, instant messages (IMs), or text messages sent and/or received within an organization a. are not included on a r
    9·1 answer
  • When writing code, how can printing be useful?
    15·1 answer
  • कम्प्युटर को पहिलो पुस्ता भनेको के हो?​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!