Last Digit Divisible by 3
EasyP3Coding
Look only at the last decimal digit of num. Return "Divisible" if that digit is divisible by 3 (0, 3, 6 or 9), otherwise return "Not Divisible". This is not the same as asking whether num itself is divisible by 3.
Example 1
- Input
- num = 123
- Output
- "Divisible"
- Why
- The last digit is 3.
Example 2
- Input
- num = 124
- Output
- "Not Divisible"
- Why
- The last digit is 4.
Example 3
- Input
- num = 10
- Output
- "Divisible"
Constraints
- 0 <= num <= 10^9
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.