# Divisibility Tests

James Chegwidden

Author

Ranch Hand

Ranch Hand

Posts: 201

posted 13 years ago

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.

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.

Author and Instructor, my book

Marilyn de Queiroz

Sheriff

Posts: 9067

12

posted 13 years ago

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.

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

Jignesh Malavia

Author

Ranch Hand

Ranch Hand

Posts: 81

posted 13 years ago

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 ]

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 ]

D. Rose

Ranch Hand

Posts: 215

James Chegwidden

Author

Ranch Hand

Ranch Hand

Posts: 201

posted 13 years ago

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.

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.

Author and Instructor, my book