Relative ratio of "1" in binary number - MATLAB Cody - MATLAB Central

Problem 1547. Relative ratio of "1" in binary number

Difficulty:Rate

Input(n) is positive integer number

Output(r) is (number of "1" in binary input) / (number of bits).

Example:

  • n=0; r=0
  • n=1; r=1
  • n=2; r=0.5

Solution Stats

67.81% Correct | 32.19% Incorrect
Last Solution submitted on May 06, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
3
5
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

Basics - Binary Logic Image
Basics - Binary Logic
  • 10 Problems
  • 978 Finishers

Problem Recent Solvers1495

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page