Wrapped math in int constructor and added {} to for loop
Header changes to get code compiling under Visual Studio