Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started