Problem 2270. Bit calculation
Give me the count of numbers from 1 to n having their last two bits as 0.
For example
function y = ret_count(4)
y = x;
end
Here 4 means you have to check the numbers between 1 to 4.
So the answer will be 1 as binary value of 4 is 00000100.
Here n in the function is the number of numbers to be checked starting from 1.
Solution Stats
Problem Comments
-
1 Comment
Nguyen Gia
on 28 Mar 2022
i think cody has problem with input argument of type "double". When I use Matlab IDE i got the total correct answer
Solution Comments
Show commentsProblem Recent Solvers217
Suggested Problems
-
105650 Solvers
-
Extract leading non-zero digit
2178 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
776 Solvers
-
Numbers spiral diagonals (Part 1)
210 Solvers
-
Number of Even Elements in Fibonacci Sequence
1436 Solvers
More from this Author8
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!