0
$\begingroup$

Need formula for:

f(x) => y

where x and y are:

0..4 => 1

5..14 => 2

15..29 => 3

30..49 => 4

etc.

i also need the opposite:

f(a) => b,c

where a,b and c are:

1 => 0,5

2 => 5,10

3 => 15,15

4 => 30,20

I'm stumped. Thanks in advance! I'm currently pursuing getting the largest consecutive numbers which satisfy n * (n+1) / 2 by getting a sqrt on the sum (after dividing by 5) since the sums are scaled x5.

1 Answers 1

1

Divide by 5, multiply by 8, add 1, take the square root, divide by 2, and round to the nearest integer.

The second doesn't seem to be the "opposite" of the first, as 2 goes to 5, 10 instead of 5, 14, and 3 goes to 15, 15 instead of 15, 29, etc. Which did you want?

  • 0
    the 5,10,15,20 were the lengths of the intervals that is what i needed. i'm scratching my head trying to figure out how the multiply by eight and rounding is working from your formula... verifying it works for me now...brb2011-12-02
  • 0
    after looking at that 25k next to your name i guess i really didn't need to verify (it worked!). i could use the rest of the answer for that upmark and my undying love ;-) essentially in a nutshell what i am doing is translating points to leveling in a computer program. points will always be incremented and from points i wanted to simulate leveling as so (each new level has a length of 5 more points than the last): 0 => level 1 (0 of 5) 1 => level 1 (1 of 5) 2 => level 1 (2 of 5) 3 => level 1 (3 of 5) 4 => level 1 (4 of 5) 5 => level 2 (0 of 10) 6 => level 2 (1 of 10) etc...2011-12-02
  • 0
    well i just took your formula and did a min = n * (n-1) / 2 * 5 and max = (n+1) * n / 2 * 5 and used [points-min, max-min] to get the min and range length and it is working awesome and so are YOU! I tried upvoting your answer and it said i don't have enuf reputation to do that. anyway the answer was accepted...and thanks again. you rock.2011-12-02
  • 0
    We aim to please.2011-12-02