I found this little gem while browsing for books at amazon. I have not verified that it actually is from the book but if it is... wow... I especially like how he verifies i%2 != 0 and i%4 != 0 just to make sure he doesnt miss those pesky odd numbers dividable by four...
See http://www.amazon.com/review/product/0471654647/ref=cm_cr_dp_hist_1?%5Fencoding=UTF8&filterBy=addOneStar
The only good thing about this book is the table of contents ( 1 generous star for that). If you've written C/C++ professionally for a living, you wouldn't stand looking at the code snippets in this book except some parts that's copied from the open source Quant Lib. Furthermore, the computational errors in the book shows you how careless the code examples are: On page 85, it has a function which is pupported to return the smallest prime greater than or equal to N:
inline long generatePrime(long N) {
Long i = N;
bool flag = false;
do {
// check if number is prime
if( ( i%2 != 0 ) && (i%3!=0) && (i%4 != 0) && (i%5 != 0) && (i%6 != 0)
&& (i%7 != 0) && (i%8 !=0) && (i%9 != 0) )
flag = true;
else
i++;
} while ( flag != true);
return i;
}
Is this a great mathematical discovery or what? Try this function with N=121! Just don't bet any money on it!
I didn't buy the book.