n&n-1  is the expression to find out if n is a power of 2...If n&n-1 returns
0 its a power of 2 else its not.
And what sunny said is also ryt....

On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal <sunny816.i...@gmail.com>wrote:

> @cegprakash
> Expression resets the least significant set bit
>
>
> On Sat, Jul 2, 2011 at 3:20 PM, mohit goel <mohitgoel291...@gmail.com>wrote:
>
>> May be this can work.....give any counter example...
>> int count;
>> main()
>> {
>>       int l,rope,cuts;
>>       scanf("%d%d",&l,&rope);
>>       count =0;
>>
>>        find_cuts(l,rope);
>>        printf("cuts needed is %d",count);
>>        getch();
>>        return 0;
>>        }
>>
>>  int find_cuts(int l,int rope)
>>
>>  {
>>
>>     if(l==rope)
>>     return count;
>>      count++;
>>      printf("%d",count);
>>      l=l/2;
>>      if(l==rope)
>>      return count;
>>      if(rope>l)
>>      rope =rope-l;
>>
>>      find_cuts(l,rope);
>>
>>
>>  }
>>
>> --
>> 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.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> 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.
>

-- 
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