Cody

Problem 42415. Divisible by 13

Created by goc3 in Community

Write a function to determine if a number is divisible by 13. Similar to the number seven, this can be done by a few different methods:

  1. Form the alternating sum of blocks of three (separated at the comma locations). Apply this recursively until a three-digit number remains. If this number is divisible by 13, then so is the original number. This three-digit number can also be further reduced using one of the other methods below.
  2. Add four times the last digit to the remaining number. Apply recursively until a two-digit number remains. As before, if this number is divisible by 13, then so is the original number.
  3. Similar to the previous method, multiply the last digit by nine and subtract it from the remaining number. Apply recursion, etc.

Some of the function restrictions have been lifted.

Previous problem: divisible by 12. Next problem: divisible by 14.

Solution Stats

40.91% Correct | 59.09% Incorrect
Last solution submitted on Nov 22, 2018

Recent Solvers34

Suggested Problems

More from this Author161

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!