Problem 42413. Divisible by 11
Pursuant to the first problem in this series, this one involves checking for divisibility by 11.
Write a function to determine if a number is divisible by 11. Like the number seven, this can be done by a variety of methods. Some are:
- Form the alternating sum of the digits (e.g., positive even digits and negative odd digits). Apply recursively until a two-digit number results. If that result is divisible by 11, then so is the original number.
- Add the digits of the number in blocks of two from right to left. Apply recursively, as needed, and check for divisibility as stated in the previous method.
- Subtract the last digit from the remaining number (e.g., 649: 64 - 9 = 55). Apply recursion, as needed.
- Add ten times the last digit to the remaining number. Apply recursion, as needed. For example: 737: 73 + 70 = 143: 14 + 30 = 44.
- Etc.
Previous problem: divisible by 10. Next problem: divisible by 12.
Solution Stats
Problem Comments
-
3 Comments
Jean-Marie Sainthillier
on 16 Aug 2015
Grant, your divisible series should become a challenge by its own right.
goc3
on 18 Aug 2015
Thanks for the vote. We'll see if the Cody team agrees. I just added a few more problems to the series today to round it out.
ME
on 11 Dec 2017
Nice problem - deceptively tricky.
Solution Comments
Show commentsProblem Recent Solvers165
Suggested Problems
-
2245 Solvers
-
605 Solvers
-
Convert a numerical matrix into a cell array of strings
1830 Solvers
-
571 Solvers
-
469 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!