See if you can write code to do this: A number is divisible by 7 if and only 7 divides the new number found by doubling the units digit of the original number subtracted from the number obtained by dropping the units digit from the original number. A number is divisible by 11 if and only if 11 divides the difference of the sum of the digits whose place values are odd powers of 10 and the sum of the digits whose place values are even powers of ten. These formulas work when you try on paper. Now try on the computer.

Originally posted by James Chegwidden: A number is divisible by 7 if and only 7 divides the new number found by doubling the units digit of the original number subtracted from the number obtained by dropping the units digit from the original number.

For example?? 14 is the number 4 * 2 = 8 14 drop the 4 = 10 10 - 8 = 2 which is the multiple of 7 that goes into 14.

However 21 is the number 1 * 2 = 2 21 drop the 1 = 20 20 - 2 = 18 How does this relate to a multiple of 7??

I guess I don't understand the question.

JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt

Originally posted by Marilyn de Queiroz: I guess I don't understand the question.

See if my comments in (parenthesis) help. "A number is divisible by 7 if and only if 7 divides the new number found by doubling the units digit of the original number subtracted from the number obtained by dropping(removing, not subtracting) the units digit from the original number (so that the total number of digits in the original number is reduced by 1)." [Hint: If the new number found is itself 2 or more digits, then the above must be applied on the newly found number, till you get -7, 0, or 7] For example, if 3192 is the number Split 3192 as 319 and 2 then calculate 319 - 2*2 that is 319 - 4 that is 315 Split 315 as 31 and 5 then calculate 31 - 5*2 that is 31 - 10 that is 21 Split 21 as 2 and 1 then calculate 2 - 1*2 that is 2 - 2 that is 0 (Edited to correct some mistakes. not sure what i was thinking at that time) [ June 01, 2003: Message edited by: Jignesh Malavia ]

Hi, I tried this for 49 and got stuck. 49 4-(9*2)=4-18=-14 -1-(4*2)=-9 -9 is not divisible by 7 but if we ignore -ve sign and just go with 14 in first step then answer comes to be -7 and it's OK. Can somebody ecplain how to handle such cases?

James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201

posted

0

See if my comments in (parenthesis) help. "A number is divisible by 7 if and only if 7 divides the new number found by doubling the units digit of the original number subtracted from the number obtained by dropping(removing, not subtracting) the units digit from the original number (so that the total number of digits in the original number is reduced by 1)." [Hint: If the new number found is itself 2 or more digits, then the above must be applied on the newly found number, till you get -7, 0, or 7] For example, if 3192 is the number

She is correct I mistated the problem. 49 = 4 - 18 = -14 -14 = -1 + 8 = 7 7 divides 7 so 49 is a divisible by seven. The double, drop, and subtract method.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com