This is my first post here and found it through Stack Overflow. I am a web designer but I am currently pulling my hair out over the lack of my mathematical knowledge.
On a site displaying a category, there may be a scenario where a user will put subcategories and products within a parent category.
On these pages (categories) where products are displayed, there is a "showing $N$ to $I$ of $T$ products" message (e.g. "showing 1 to 6 of 10 products").
So I am in a rut about how I am to calculate this to only take into account the products and not the categories.
Here's what I know (variables):
$E =$ the current page number (there can be many pages to split up the view)
$F =$ the amount of products or subcategories allowed on any 1 page
$Y =$ the total amount of subcategories being displayed in this category
$L =$ the total amount of products displayed in this category
Also the subcategories are always displayed first before the products.
If anyone can help me out or give a push in the right direction, it would be much appreciated.
EDIT
as per the solution below, here is the PHP interpritation: (valiables are in relation to the post and relating comments)
function f( $x, $f, $y, $l ) { return ( ( $x * $f ) - $y < 0 ? 0 : ( ( $x * $f ) - $y > $l ? $l : ( $x * $f ) - $y ) ); } $n = 1 + f($e-1, $f, $y, $l); $i = f($e, $f, $y, $l); echo 'Showing ' . $n .' to ' . $i . ' of ' . $l . ' Products';