0
$\begingroup$

I have difficulties to come up with a formula to achieve this in my programming challenge :

  • The input number ranges between 100 to 10.000 (all integers), then the output would be 0.1 - 10, so the formula is (input / 1000)
  • But as the number increases, the formula also changes. From the range of 10.000 - 100k, the output would be 10 - 20. The input of 20.000 will result in 11, 30.000 will result in 12, 25.000 will result in 11.5. This is where i get lost, as i dont know how to come up with the formula to get the results based on the input in this range.

My question would be :

  • As somebody that is getting interested in learning math again, what 'type' of math is it for this kind of problem ? Algebra ?
  • How do i come up with the formula ? I've tried dividing the inputs with the output i expect, but the growth of the number isnt 'predictable', like a list of growing numbers with a formula. Here's what i've come up with with the format of : 10k(1k), 20k(1.818k), 30k(2.5lk), 40k(3.076k).

And i apologize for the 'approximate' tags i can come up with at this level.

$\endgroup$
1
$\begingroup$

It looks like $f(x)=\begin {cases} x/1,000 & x \le 10,000 \\ x/10,000+9 & x \gt 10,000 \end {cases}$

but that results in $f(100,000)=19$, not $20$ There is nothing wrong with a piecewise definition. To be a function, it needs to return a single value for any input in the domain. This one is continuous, but that is not a requirement for being a function.

$\endgroup$
  • $\begingroup$ This is exactly what i needed. Thanks ! $\endgroup$ – bertie Mar 5 '14 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.