Given a value of n, for( i = iabs(n) + 3 ; i > 3 ; i = ( i & 3 ) + ( i >> 2 ) );
After the above loop, if i == 3, then n is a multiple of 3, otherwise n is not a multiple of 3. This simply is a "casting out of threes" algorithm. Dave On Aug 14, 2:45 am, richa gupta <richa.cs...@gmail.com> wrote: > can we check the divisibility of a given number by 3 withoutusing > operators like '/' or '%'. > I want the efficient solution to this problem .. > > can someone help ?? > -- > Richa Gupta > (IT-BHU,India) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---