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
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution