Problem 42418. Divisible by 16

Created by goc3 in Community

Write a function to determine if a number is divisible by 16. This can be done by a few different methods. Here are two:

  1. If a number has four or more digits, take the last three digits. Add eight to it if the thousands digit in the original number is odd (zero if even). If this three-digit number is divisible by 16, so is the original number. The resulting number can also be reduced by the following method.
  2. Take the last two digits and add them to four times the remaining number. Apply this method recursively until a two-digit number remains. As usual, if the resulting number is divisible by 16, then so is the original number.

A few of the function restrictions have been lifted.

Previous problem: divisible by 15. Next problem: divisible by n, prime vs. composite divisors.

Solution Stats

39.44% Correct | 60.56% Incorrect
Last solution submitted on Nov 22, 2018

Problem Comments

Recent Solvers49

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!