- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Check if a large number is divisibility by 15 in C++

Here we will see how to check a number is divisible by 15 or not. In this case the number is very large number. So we put the number as string.

To check whether a number is divisible by 15, if the number is divisible by 5, and divisible by 3. So to check divisibility by 5, we have to see the last number is 0 or 5. To check divisibility by 3, we will see the sum of digits are divisible by 3 or not.

## Example

#include <bits/stdc++.h> using namespace std; bool isDiv15(string num){ int n = num.length(); if(num[n - 1] != '5' && num[n - 1] != '0') return false; long sum = accumulate(begin(num), end(num), 0) - '0' * n; if(sum % 3 == 0) return true; return false; } int main() { string num = "154484585745184258458158245285260"; if(isDiv15(num)){ cout << "Divisible"; } else { cout << "Not Divisible"; } }

## Output

Divisible

- Related Questions & Answers
- Divisibility by 12 for a large number in C++ Program
- Check if a large number is divisible by 20 in C++
- To check divisibility of any large number by 9 in java
- Check if a large number is divisible by 11 or not in C++
- Check if a large number is divisible by 25 or not in C++
- Check if a large number is divisible by 3 or not in C++
- Check if a large number is divisible by 5 or not in C++
- Check if a large number is divisible by 75 or not in C++
- Check if a large number is divisible by 8 or not in C++
- Check if a large number is divisible by 9 or not in C++
- Check if a large number is divisible by 13 or not in C++
- Check if a large number is divisible by 11 or not in java
- Check if a large number is divisible by 3 or not in java
- Check if a large number is divisible by 2, 3 and 5 or not in C++
- Check if any permutation of a large number is divisible by 8 in Python

Advertisements