Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If a page can have 27 items printed on it and number of items can be any positive number then how can I find number of pages if I have number of items, I tried Modulus and division but didn't helped.

FYI, I am using C# as programming platform.

share|cite|improve this question
up vote 2 down vote accepted

If I understand the question correctly, isn't the answer just the number of total items divided by $27$ and then rounded up?

If you had $54$ total items, $54/27=2$ pages, which doesn't need to round.

If you had $100$ total items, $100/27=3.7$ which rounds up to $4$ pages.

If you had 115 total items, $115/27=4.26$ which rounds up to $5$ pages.

share|cite|improve this answer
In C#, that translates as Math.Ceil(items / 27.0). – zneak Oct 30 '12 at 16:30
Or to items / 27 + (items % 27 > 0 ? 1 : 0) if you wish to avoid the Math library. – Joost Oct 30 '12 at 16:33
I program in Java, so I'm not sure if they have this in C# where you truncate a number by converting it into an integer. In that case you can add .5 to your answer and truncate it, that would be the easiest way without the Math library. – mathguy Oct 30 '12 at 16:34
@mathguy, this just rounds a number; it needs to be rounded up. – zneak Oct 30 '12 at 16:35
@zneak I totally lost track of the problem. Thanks. =P – mathguy Oct 30 '12 at 16:36

I'm not sure if I understood you correct. Assume you have int "items" that express the quantity of items to be printed.

wholePages expresses how much whole pages will be printed, totalPages tells on how many pages you will print something. "totalPages" is calculated in easy way; it can be made shorter

int wholePages = items / 27; int totalPages = items / 27 + ( items % 27 > 0 ? 1 : 0 );

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.