Count ones - MATLAB Cody - MATLAB Central

Problem 1895. Count ones

Difficulty:Rate

Write a program to count number of ones (1s) in an integer variable input.

For example: Input x=2200112231 output y=3

Input x=99933387 Output y=0

Solution Stats

63.05% Correct | 36.95% Incorrect
Last Solution submitted on Jan 25, 2025

Problem Comments

Solution Comments

Show comments
Primes and Rough Numbers, Basic ideas
What is a rough number? What can they be used...
3
4

Problem Recent Solvers345

Suggested Problems

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