0
$\begingroup$

I get 5 or 7 and if i get 5 i need to return 7 if i get 7 i need to return 5.

i need to do this in 1 mathematical formula.

I have those:

12 - x  35 / x 

There are more solutions ?

Example in code:

public static int Transform(int x) {     return (12-x);     //return (35/x); } 
  • 4
    There are infinitely many more...2011-05-11
  • 0
    Can you show me some ? But smart ones not like `13-x-1`2011-05-11
  • 3
    Example: $\sqrt{74 - x^2}$. This can be easily generalized.2011-05-11
  • 2
    I am voting to close as NARQ.2011-05-11
  • 4
    Why are you unsatisfied with the simple ones you already have?2011-05-11
  • 0
    It's a Puzzle..2011-05-11
  • 5
    @Danpe, this isn't a puzzle site.2011-05-11
  • 2
    This is the same as finding how many functions in the Cartesian plan go through the points $(5,7)$ and $(7,5)$... which is indeed infinite.2011-05-11
  • 5
    If $h$ is an invertible function we can define $f(x) = h^{-1}(h(5) + h(7) - h(x))$. This $f$ has the property that you want. This covers the two methods you have (with $h(x)=x$ and $h(x)=\log(x)$, respectively, and quite a few more.2011-05-11
  • 1
    $f(x) = 12 - x + (x-5)(x-7)h(x)$ or $f(x) = 35/ x + (x-5)(x-7)h(x)$ etc2011-05-11
  • 1
    You can also multiply any formula you've found by (x-6)^2, of course.2011-05-11

1 Answers 1