@dave sir-your algorithm is having a complexity of n(2) but the solution
that i have given is of log(n) i guess.

On Tue, Jul 24, 2012 at 8:10 PM, Dave <dave_and_da...@juno.com> wrote:

> @Ruru:
>
> int i,j,sum=100*101/2;
> for( i = 1 ; i <= 100 ; ++i )
> {
>     j = i;
>     while( j )
>     {
>         j >> = 1;
>         sum -= j
>     }
> }
> printf("%i\n",sum);
>
> Dave
>
> On Tuesday, July 24, 2012 4:39:42 AM UTC-5, ruru wrote:
>
>> find no. of 1's in binary format of numbers from 1 to 100. like for
>> 1 to 10 answer is 17
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/c-FrS-OzdhsJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards

Lomash Goyal
*
*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to