aaronvan icon

Untitled

aaronvan | PRO | 01/29/19 06:22:21 PM UTC | 0 ⭐ | 798 👁️ | Never ⏰ | []
C++ |

420 B

|

None

|

0 👍

/

0 👎

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