# How to find that a number is divisible by 3, without using division/subtraction

By tmaheshwari

@tmaheshwari (170)

India

January 19, 2007 5:16am CST

Hi all,
A new puzzle for you again, How to find that a number is divisible by 3, without using division/subtraction etc?
I hope people will enjoy this series and take participate to encourage myself to post more and more puzzle for your brain exerciese....
Please do reply ...

11 responses

@dholey (1384)

• India

29 Jan 07

here is the correct logig .. without using +,/and %...
void main()
{
long x,y;
printf("\n ENTER ANY NUMBER ");
scanf("%ld",&x);
for(y=x;y3;y-=3)
;
if(y==3)
printf("%ld is fully divisible by 3",x);
else
printf("%ld is not fully divisible by 3",x);
}
i think it is one of the answer for your puzzle .... i am still thinking for some other option too ....
(where are you not loged for last three days ... any thing serious )

@dholey (1384)

• India

1 Feb 07

here comes the real solution... it took long time to make logic ... but MAZA AA GAYA .... HERE IS THE REAL CODE YOU CAN SEE THERE IS NO ARITHMETIC OPERATOR USED AND IT CAN BE USED TO CHECK ANY NUMBERS DIVISIBILITY .. ONE HAS TO CHENG THE VALUE OF MACRO DIV ONLY .......... THANKS DUDE TO MAKE ME A LITTLE SHARP .... I SOLVED IT ... HURRRA .... (i just have finished the logic building and testing .... you can understand the feelings of accomplishing task)
here is the code
#include
#include
#define DIV 3
void main()
{
unsigned x,y,z,c,car,k;
long v;
x=y=DIV;
clrscr();
cout v;
if (v

@swaroop_sv2003 (531)

• India

19 Jan 07

Good answer but I got a doubt. The answer is 12 and to check whether 12 is divisible by 3 we need to check it by dividing (in terms of computer programming)? But in the question it is written we cannot divide or subtract.

@vijayganesh (845)

• India

20 Jan 07

Yes, its a good puzzle.
As in division, if a number (Say m) is divided by another number (say n), then m is said to be divisible by n when remainder comes to be 0 (zero).
The same concept I am using her.
If m%3 is equal to 0 (zero)
than number is divisible by 3.
Else not.
I wrote above in accordance with the programming language.

@vijayganesh (845)

• India

20 Jan 07

Sorry I forgot one thing,
% is a modulus operator results a remainder.
Thanks.

@tmaheshwari (170)

• India

21 Jan 07

Hi Vijay,
I m very sorry, but i forget to mention that % is also not acceptable...
No subtraction, No division and No Modulus :)

@lovable_coolguy (149)

• India

20 Jan 07

first choose a number which u want to divide, now add the digits in the n u have choosen if the no is greater than 9 than add again the digits of resultant no. now if the no is 3, 6, 9 than u can divide the number by .
e.g. u choose -- 57
5+7=12 , then add 1+2=3.
now u can divide 57 by 3.

@tmaheshwari (170)

• India

21 Jan 07

Hmmm.... really intresting.....
seems like u fix that. Nice solution dear. Now, there is no need of subraction, division or modulus.....
But, can i come up with a twist, (Interesting for all algo lovers).... What if, i say No addition is allowed ???? :)
Comments are most welcome !!!!

@arpita_onlinejob (508)

• India

19 Jan 07

we can use MODULUS symbol "%" for doing this .Eg: 27%3=0 that is the remainder after division. Therefore we can conclude that when any integer number is divisible by 3 then its remainder will be 0 or else if the remainder is not 0 then the number is not divisible by 3 !!!
Eg: 28 % 3 = 1 so 28 is not divisible by 3

@tmaheshwari (170)

• India

21 Jan 07

No Arpita,
% (Modulus) is also not accepted. Well i think i should include this also in my question... sorry for this mistake:)

@tmaheshwari (170)

• India

21 Jan 07

No, this is also not accepted. Well i think i should include this also in my question... sorry for this mistake :)

@AJMSmith (113)

•

8 Feb 07

Insert a + sign between the first 2 digits of the number and sum repeatedly until you have only 1 digit left eg 1048576 - 48577 - 8581 - 589 - 94 - 13 - 4.
The result is conguent with the original number modulo 9 (-ve numbers give a result in the range -9 to -1, +ve number in the range 1 to 9 and zero is the only number to give zero). Multiples of 3 give a multiple of 3 as a result.
Doing the same with PAIRS of digits (spltting the number in pairs from the right) can be used as a test for 11 as a factor.
1 048576 - 4 8577 - 85 81 - 1 66 - 67. 1048576 is 7 modulo 11. A multiple of 11 would give a multiple of 11 here.
How it works.
by summing the digits (eg 1048576 to 148576 what you are doing is subtracting 0.9 times the value of the first digit from the number this is a multiple of 9 so the result is unchanged modulo 9ef from 1048576 to 148576 you subtract 900000. Since 3 is a factor of 9 any multiple of 3 must also ne a multiple of 3 when the number is taked mod 3
the 11 test works because you are subtracting multples of 99 (rather than 9) and the result (number mod 99) is congruent with the original number mod 11 (11 is a factor of 99).

@bkpdp1 (923)

• India

25 Jan 07

Hey, a good question. I am trying to solve it. If i will show you a half glass of water, you may say it is half full glass or half empty glass. Similary according to your question Say a number = 24564. So 2+4+5+6+4 = 21, So if you take HCF (Highest Common Factor) of 21, it will be either 3 or 7. (I have not devided or substracted) As 3 is there, so the number is divisible by 3 and if HCF of 21 does not consist of 3, then it will never be devided by the number. Hope you got my point..

@lovable_coolguy (149)

• India

25 Jan 07

take a no which u want to divide by 3.
e.g.:- no is 23451.
2+3+4+5+1=15, 1+5=6. 6 is divisible by 3 .so 23451 is divisible by 3.