Multiples of 3 or 7 | A better C ++ program to find count of all numbers that multiples ; Returns count of all numbers smaller than or equal to n and multiples of 3 or 7 or both ; Driver code
#include <iostream> NEW_LINE using namespace std ; int countMultiples ( int n ) { return n / 3 + n / 7 - n / 21 ; } int main ( ) { cout << " Count ▁ = ▁ " << countMultiples ( 25 ) ; }