16. Divisible by Three and Five
Foundation1000 ms256 MBSolved by 0%
Read an integer and print:
Bothif it is divisible by 3 and by 5Threeif it is divisible by 3 onlyFiveif it is divisible by 5 onlyNeitherif it is divisible by neither
Check the combined case first, or a number like 15 will be reported as just Three.
Constraints - `-1000000 ≤ n ≤ 1000000`
Input
A single line containing one integer n.
Output
Print exactly one word: Both, Three, Five or Neither.
Input15
OutputBoth
Noteis divisible by three and by five, so the combined case must be checked first
Input9
OutputThree
Noteis divisible by three only
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.