You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I first did the exercise the way it is done here, but I think there is a fundamental misunderstanding of the text. The number that has to be entered is not the divisor, but the dividend. Hence the "divisible by" in the exercise. For example, 100 (dividend) is entered and checked for 2, 3, 4 (divisor) and not 2 (divisor) checked for 80, 90, 100 (dividend).
A correct approach to solve this exercise can be found on https://github.com/pezy/CppPrimer/blob/master/ch14/ex14_43.cpp in my opinion.
This approach might be a bit odd at first (why defining std::modulus mod? Why not doing the straight solution by using %?) But using std::modulus is what the exercise asks for and since we have to enter a dividend and not a divisor, something like the solution in this link seems to me the way to go for.
The text was updated successfully, but these errors were encountered:
I first did the exercise the way it is done here, but I think there is a fundamental misunderstanding of the text. The number that has to be entered is not the divisor, but the dividend. Hence the "divisible by" in the exercise. For example, 100 (dividend) is entered and checked for 2, 3, 4 (divisor) and not 2 (divisor) checked for 80, 90, 100 (dividend).
A correct approach to solve this exercise can be found on https://github.com/pezy/CppPrimer/blob/master/ch14/ex14_43.cpp in my opinion.
This approach might be a bit odd at first (why defining std::modulus mod? Why not doing the straight solution by using %?) But using std::modulus is what the exercise asks for and since we have to enter a dividend and not a divisor, something like the solution in this link seems to me the way to go for.
The text was updated successfully, but these errors were encountered: