Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function NumberOfBits(n) , that takes as input a number, n, where n is bigger or equal to 1, and returns the minimum number

Write a function NumberOfBits(n) , that takes as input a number, n, where n is bigger or equal to 1, and returns the minimum number of bits that n needs to be represented in binary. The number of bits needed for representation in binary for any integer is equal to 1 + the number of times you can divide that number by 2. for example , the number 10 can be divided by 2 three times : 10/2 = 5 , 5/2= 2.5 , 2.5/2 =1.25. thus, 10 need (1 + 3=) 4 digits to be represented in binary as 1010.(provide complete and meaningful docstrings)

>>>NumberOfBits(4) 3

>>>NumberOfBits(15) 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions

Question

Which form of proof do you find most persuasive? Why?

Answered: 1 week ago