Problem description:
The modulo of 0 in C++ is not throwing an error.
The following code returns the correct factorCount
int factorCount(int n) {
int count = 0;
for (int i = 0; i <= n; i++) {
if (n % i == 0) {
count++;
}
}
return count;
}
Expected behavior:
This should return an math exception.
Actual behavior:
Returns the actual coount
Steps to reproduce:
Run the following code:
#include <iostream>
using namespace std;
//Function Prototypes
int factorCount(int n);
int main() {
cout << factorCount(12) << endl;;
return EXIT_SUCCESS;
}
int factorCount(int n) {
int count = 0;
for (int i = 0; i <= n; i++) {
if (n % i == 0) {
count++;
}
}
return count;
}
Bug appears at this link:
N/A
Browser/OS/Device:
Chrome/MacOS