 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 divisible by 75 or not in C++
Here we will see how to check a number is divisible by 75 or not. In this case the number is very large number. So we put the number as string.
A number will be divisible by 75, when the number is divisible by 3 and also divisible by 25. if the sum of digits is divisible by 3, then the number is divisible by 3, and if last two digits are divisible by 25, then the number is divisible by 25.
Example
#include <bits/stdc++.h> using namespace std; bool isDiv75(string num){    int n = num.length();    long sum = accumulate(begin(num), end(num), 0) - '0' * n;    if(sum % 3 != 0)       return false;       int last_two_digit_val = (num[n-2] - '0') * 10 + ((num[n-1] - '0'));    if(last_two_digit_val % 25 == 0)       return true;       return false; } int main() {    string num = "1754586672150";    if(isDiv75(num)){       cout << "Divisible";    }else{       cout << "Not Divisible";    } }  Output
Divisible
Advertisements
 