Check if a large number is divisibility by 15
Given a very large number. Check its divisibility by 15.
Examples:
Input: "31"
Output: No
Input : num = "156457463274623847239840239
402394085458848462385346236
482374823647643742374523747
264723762374620"
Output: Yes
Given number is divisible by 15
A number is divisible by 15 if it is divisible by 5 (if the last digit is 5 or 0), and it is divisible by 3 (if sum of digits is divisible by 3).
Below is the implementation of above approach.
C++
Java
Python3
C#
Javascript
PHP
Output
No Yes
Time complexity: O(number of digits)
Auxiliary space: O(1)
Contact Us