why doesn´t ((num / i) % 1 == 0) work in C++ when num is a double? and how would I instead write this code, that checks for factorials by checking if it leaves a remainder (etc 0.3333).
int getFactorials (double num)
{
int total = 0; // if (total / 2) is equal too 'num' it is a perfect number.
for (int i = 1; i < num; i++)
{
if ((num / i) % 1 == 0)
{
cout << i << endl;
}
}
return 0;
}
Actually what you want to do is check if
nis divisible byiso all you have to change isinto
You should know that this is error-prone because you are using
doubleas a type fornum. You should use anintinstead.