The simplest formula to calculate page count?
Solution 1:
Force it to round up:
totalPage = (imagesFound.Length + PageSize - 1) / PageSize;
Or use floating point math:
totalPage = (int) Math.Ceiling((double) imagesFound.Length / PageSize);
Solution 2:
NOTE: you will always get at least 1 page, even for 0 count, if the page size is > 1, which is what I needed but may not be what you need. A page size of 1(silly but technically valid) and a count of 0 would be zero pages. Depending on your needs you may want to check for a zero value for count & page size of 1
int pages = ((count - 1) / PAGESIZE) + 1;
Solution 3:
Actually, you are close to the best you can do. About the only thing that I can think of that might be "better" is something like this:
totalPage = (imagesFound.Length + PageSize - 1) / PageSize;
And the only reason that this is any better is that you avoid the if statement.