top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Find amount of numbers that are between 1 and 100 inclusive, when converted to binary have a digit sum of less than 5?

+1 vote
702 views
Find amount of numbers that are between 1 and 100 inclusive, when converted to binary have a digit sum of less than 5?
posted Jun 14, 2016 by anonymous

Share this puzzle
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

There are 87 decimal numbers from 1 to 100 (including 1 and 100)
That have their binary version's digits add upto 4 or as given in the question less than 5.

answer Jun 18, 2016 by Tejas Naik
Here is the c code I used.
#include <stdio.h>
#include<math.h>
int main ()
{
    int a,b,c,d,count;
    count=0;
    for (a=1;a<101;a++)
    {
        b=a;
        d=0;
        while (b>0)
        {
            c=b%2;
            b=b/2;
            d=d+c;
        }
       if (d<5)
        {
            count=count+1;
        }
    }
    
   printf("There are %d many decimal numbers which have thier binary version's digits add upto or lesser than 5",count);
    
}
i have yet to study the listing but KUDOS



Similar Puzzles
0 votes

Two natural numbers have a sum of less than 100 and are greater than one.

John knows the product of the numbers and Jacob knows the sum of numbers.

The following conversation takes place between them:
John: ‘I am not aware of those numbers.’
Jacob: ‘I knew you wouldn’t be. I am not aware myself.’
John: ‘Now I know them!’
Jacob: ‘Now I know them, too!’

What are the two numbers?

+1 vote

Find the sum of all the prime numbers larger than 2 less than 10^12 that are 1 more than a perfect square. Because the number can get pretty big provide the answer mod 1007.

Note: Problem shouldn't take much more than one minute if your answer is taking too long consider looking for optimizations.

...