![]() |
VOOZH | about |
Given a string s representing a non-negative decimal number, determine whether the number is divisible by 8. Return true if it is divisible by 8, otherwise return false.
Examples:
Input: s = "16"
Output: true
Explanation: The given number is divisible by 8. So the answer is true.
Input: s = "54141111648421214584416464555"
Output: false
Explanation: Given Number is not divisible by 8. So the answer for this is false.
A number is divisible by 8 if its last three digits are divisible by 8. So, check only the last three digits when the string length is greater than 3; otherwise, check the whole number.
1