VOOZH about

URL: https://www.geeksforgeeks.org/dsa/check-large-number-divisibility-15/

⇱ Check if a large number is divisibility by 15 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Check if a large number is divisibility by 15

Last Updated : 18 Sep, 2023

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.


Output
No
Yes

Time complexity: O(number of digits) 
Auxiliary space: O(1)



Comment