@arun : we are not supposed to use / operator. but in ur algo u r using / or % has to be used to check wether the diff is divisible by 3. We can do like dis... - add all d digits of the no. - if the result is less than 10, add all the digits of the result again. - continue step2 if the result is still less than 10 - if the result is either 0, 3 , 6 or 9 den the no. is divisible by 3.
example 1 : num = 12345 sum1 = 15 (sum > 10) sum2 = 6 since sum < 10, we stop here and since final sum = 6 ....so the given no. is divisible by 3 On Fri, Aug 14, 2009 at 3:09 PM, Arun N <arunn3...@gmail.com> wrote: > take an number find its binary > add all odd bits and even bits seperately > now check if the difference is divisible by 3 > if yes it is > say 6 110 -----> 1+0 - 1 =0 > 9 1001 -----> 1+0 - 0+1 = 0 > 12 1100 ------> 1+0 - 1+0 = 0 > Arun, > > On Fri, Aug 14, 2009 at 1:15 PM, 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) >> >> >> > > > -- > Potential is not what U have, its what U think U have!!! > It is better to worn out than rust. > > > > > > -- Best Wishes & Regards Thank You Yogesh Aggarwal B.Tech(IT), University School of Information Technology GGS Indraprastha University Delhi mailto: yogesh.aggarwa...@gmail.com #9990956582 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---