2021年3月11日星期四

Function with multiple possible arguments that will never return the same value given any sequence of arguments

Let's say you have a function that takes both x and y, real integers, as arguments. What would you put inside that function, using only mathematical operators, so that no two given sequences of arguments could ever return the same value?

Example of a function that fails at doing this:

function myfunction(x,y){   return x * y;  }    // myfunction(2,6) and myfunction(3,4) will both return 12  // myfunction(2,6) and myfunction(6,2) also both return 12.  
https://stackoverflow.com/questions/66593033/function-with-multiple-possible-arguments-that-will-never-return-the-same-value March 12, 2021 at 09:42AM

没有评论:

发表评论