string factors56(int n) {
ostringstream stream;
if ((n % 5 == 0) && (n % 6 == 0)) {
stream << n << " is divisible by both 5 and 6";
return stream.str();
}
else if ((n % 5 == 0 || n % 6 == 0) && !((n % 5 == 0) && (n % 6 == 0))) {
stream << n << " is divisible by 5 or 6, but not both";
return stream.str();
}
else {
stream << n << " is not divisible by either 5 or 6";
return stream.str();
}
}
Comments