write a program in Java to enter a number and display the first three multiples of the number
(using functions)
Answers
Answered by
2
// A Simple C++ program to find count of all
// numbers that multiples
#include<iostream>
using namespace std;
// Returns count of all numbers smaller than
// or equal to n and multples of 3 or 7 or both
int countMultiples(int n)
{
int res = 0;
for (int i=1; i<=n; i++)
if (i%3==0 || i%7 == 0)
res++;
return res;
}
// Driver code
int main()
{
cout << "Count = " << countMultiples(25);
}
Similar questions