Re: [algogeeks] Bit Magic ....Always Stuck ..

2011-03-02 Thread Himanshu Sachdeva
ui nextsmallest( ui n) { ui x; int ctr=-1; x= (n&~(n-1)); // the lowest bit set in 'n' while( x&n)// finds the number of consecutive bits set from the lowest one { x<<=1; ctr++; } n^=x; n&=(~(x-1)); n+=(1

Re: [algogeeks] Bit Magic ....Always Stuck ..

2011-03-02 Thread Himanshu Sachdeva
ot;); } I hope this would suffice. Ofcourse, this piece of code fails for all numbers having all their 1's in consecutively highest locations and you ought to be knowing why it fails. -- Himanshu Sachdeva -- You received this message because you are subscribed to the Google Groups "

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread Himanshu Sachdeva
quot;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=e

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread Himanshu Sachdeva
should be i==101 instead. On 3/1/11, Himanshu Sachdeva wrote: > #include > int i=1; > int main() > { > printf("%d\n",i++); > return i==100?0:main(); > } > > > -- > Himanshu Sachdeva > -- Himanshu Sachdeva -- You received this message b

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread Himanshu Sachdeva
#include int i=1; int main() { printf("%d\n",i++); return i==100?0:main(); } -- Himanshu Sachdeva -- 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 u

Re: [algogeeks] printing without loop

2011-03-01 Thread Himanshu Sachdeva
telligent >>>> effort" >>>> >> - >>>> >> John Ruskin >>>> >> >>>> >> >>>> > >>>> > -- >>>> > You received this message because you are subscribed to the Google >>