-1

sorry i couldn't think of better title

so i have a number lets say 13(variable) and by dividing it to 5 (constant) i get my groups (3 in this example )

1 => 1-5
2 => 6-10
3 => 11-13

now i want to know group of each number between 1-13

groups = roundsUp(number / 5) ;

in this example what is the formula to get group(1 or 2 or 3) of each number (1 to 13)

max
  • 101
  • You seem to already understand how to get from item number $i$ to group number $g$, which might be written $g = \lceil i/5\rceil$; what exactly is the question? – Joffan Mar 16 '15 at 17:49
  • @Joffan i said my question in the last line , i want a formula to find out group of each number between 1-13 for example numbers 1 to 5 are in group 1 and 6-10 are in group 2 and 11-13 in group 3 – max Mar 16 '15 at 18:13

1 Answers1

1

You seem to already understand how to get from item number $i$ to group number $g$, in the formula you have given - your groups = roundsUp(number / 5); which might be written $g=\lceil \frac{i}{5}\rceil$ (those are doing the same thing - $\lceil x \rceil$ is the smallest integer greater than or equal to $x$).

If you want the first item number of a group, it's $i_F=5(g-1) +1$, and the last item number in group $g$ is of course $i_L=5g$, except that you need to check that this does not exceed the last item number.

I've written these (in particular $i_F$) so that if the constant $5$ changes, you can just swap the new number in place.

Are any or all of these what you were asking for?

Joffan
  • 39,627