I think it has to do with the fact that numberofpages is a string
instead of an integer. In the irb:
number_of_pages = 5
number_of_pages % 2 => 1
number_of_pages = ‘5’
number_of_pages % 2 => 5
So the test (numberofpages % 2 != 0) will always return a false, unless
numberofpages was 0 in the first place.
Workaround: use ( numberofpages.to_i % 2 ) instead.