I need to build a function that given a number it either returns the number within the set (not stored) or returns an approximation of the possible highest and lowest number within the set for the given input.

For example the following is the set of numbers. This set is not stored so the function should be created when this set is created.

Set = {1, 2, 10, 15, 20, 31, 50, 90, 101, 200}

If input = 20. Output should be 20

If input = 25. Output should be 20 (lowest) and 31 (highest).

Is this possible?

  • 1
    $\begingroup$ Are you asking for an algorithm to perform this computation? $\endgroup$
    – angryavian
    Oct 31 '19 at 7:24
  • 1
    $\begingroup$ What do you mean by "possible" ? You could just define the following: Let $\mathbb{R}^n$ be the set of sets of real numbers of size $n$. Then, when set $A\in \mathbb{R}^n$, $$ f_A: \mathbb{R} \to \mathbb{R}^n: f_A(x) = \left\{ \begin{split} (x), & ~\text{if } x \in A \\ (\max{A}, \min{A}),& ~\text{otherwise} \end{split} \right. $$ $\endgroup$
    – Matti P.
    Oct 31 '19 at 7:26
  • 1
    $\begingroup$ What do you mean by not stored? $\endgroup$ Oct 31 '19 at 7:30
  • $\begingroup$ @angryavian - Yes. An algorithm or a function. $\endgroup$ Oct 31 '19 at 7:34
  • 2
    $\begingroup$ I have a feeling that this is more of a programming question than mathematics question. From a mathematical point of view, it's not difficult to just define this kind of function. $\endgroup$
    – Matti P.
    Oct 31 '19 at 7:36

Your Answer

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

Browse other questions tagged or ask your own question.