Divisible by 8 - MATLAB Cody - MATLAB Central

Problem 42410. Divisible by 8

Difficulty:Rate

Pursuant to the first problem in this series, this one involves checking for divisibility by 8.

Write a function to determine if a number is divisible by 8. This can be done by the following method:

  1. Check the last three digits for divisibility by eight. If that portion of the number is divisible by eight, then so is the original number. That three-digit number can be further reduced by summing four times the hundreds digit, two times the tens digit, and the ones digit. As with methods for other numbers, this factor/sum step can be applied recursively until a single-digit number results.

Previous problem: divisible by 7. Next problem: divisible by 9.

Solution Stats

34.7% Correct | 65.3% Incorrect
Last Solution submitted on Apr 20, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers234

Suggested Problems

More from this Author139

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!