0
$\begingroup$

I have a math problem. I need to understand a pattern here so I don't have to write multiple range code. Here is the situation. Users will enter a number between $1-22$. The entry number needs to be divided by $46$. The max results that can get is $\frac{22}{46}$ which is $0.478$. Once I get that results I need to enter 1 into partial box. Now if the user enter any number between $23 \leq x \leq 46$ , I divide that number (can be any in that range) with 46. In this case I need to enter one into full box field. (ex: $\frac{29}{46} = 0.6303$) if the user enters a number between $47 \leq x \leq68$ there will be 1 full and 1 partial.

$69 \leq x \leq 92$ there will be 2 full No Partial $93 \leq x \leq 114$ 2 full and 1 Partial ( I need to enter 2 into the full box and 1 into partial) $115 \leq x \leq 130$ will be $3$ full No Partial ... and so On

Can someone tell me a patter or algorithm where I can find out when I need to have partial and when full or when I need full and partial at the same time?

  • 0
    @Peter yes I am sorry it was a type its 46 I fixed it2017-02-09
  • 0
    @Peter thank you I did2017-02-09
  • 1
    Where did these numbers (22, 46, 68, 92, 114, 130) come from? It would help in identifying any pattern. The ranges seem arbitrary and I don't know what "full" and "partial" are supposed to mean.2017-02-09
  • 0
    @Waffle the range comes from 23. each full machine can support up to 46 ports. in first round up to 22 is partial machine which is a machine with 46 ports . after that a machine can support any range between 23 to 46. from 46 to 68 is one partial machine for the first 22 port and then one full for the rest 69-92 is 2 full machines example 114-46=68 68 -46 = 22 now 22 is partial so you need two 46 machines and one partial2017-02-09
  • 0
    It looks like the pattern is $23n+\frac{(-1)^n-1}{2}$ for that number sequence. The number after 114 would be 138, though, and not 130.2017-02-09
  • 0
    @Waffle that is amazing and correct. but how would I know if the number is 116 I would want 3 full ones and no partial2017-02-10
  • 0
    @Waffle by the way those are ranges of number 22 23 24...46 and so on2017-02-10
  • 0
    It looks like full is $\lfloor{n/2}\rfloor$ and partial is $n\bmod{2}$ where $n$ is from smallest value of $23n+\frac{(-1)^n-1}{2}$ greater than the given number.2017-02-10
  • 0
    for a given number $x$, $v = \lceil(x - \frac{(-1)^{\lceil x/23\rceil}-1}{2})/23\rceil$, full = $\lfloor v/2\rfloor$ and partial = $v\bmod2$2017-02-10
  • 0
    @Waffle damn how did you come up with that?2017-02-10
  • 0
    Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/53364/discussion-between-benji-r-and-waffle).2017-02-10

0 Answers 0