Fixed #6 by changing a division to integer division, as it should.