- Related Questions & Answers
- Check if a large number is divisible by 2, 3 and 5 or not in C++
- 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 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 any large number is divisible by 17 or not in Python
- Check if any large number is divisible by 19 or not in Python
- Check if a number is divisible by 23 or not in C++
- Check if a number is divisible by 41 or not in C++
- Check if a large number is divisible by 20 in C++

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

Here we will see how to check a number is divisible by 5 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 5, So to check divisibility by 5, we have to see the last number is 0 or 5.

#include <bits/stdc++.h> using namespace std; bool isDiv5(string num){ int n = num.length(); if(num[n - 1] != '5' && num[n - 1] != '0') return false; return true; } int main() { string num = "154484585745184258458158245285265"; if(isDiv5(num)){ cout << "Divisible"; }else{ cout << "Not Divisible"; } }

Divisible

Advertisements