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); } 
  • 1
    You can also multiply any formula you've found by (x-6)^2, of course.2011-05-11

1 Answers 1

5

return x ^ 2;

Are you sure you aren't missing any constraints?

  • 0
    Since this isn't SO, a "where `^` is bitwise XOR" would have went a long way. :)2011-05-11