0
$\begingroup$

It's been a long time since I took discrete math in college and I was never good at it, so I'm asking for some help with something I need to populate a chart in C#.

X = 2, the output for 2 is 0, and with each iteration the input increases by 3 and the output increases by 1.

input | output
______|_______
  2   |   0
______|_______
  5   |   1
______|_______
  8   |   2

and so on. I tried finding a value for a for input % a = output but didn't come up with anything. I feel like this is a simple problem but it just isn't my thing. Is there a function that given an input will give me the proper output? I need this to work, like if I put in 23 I need to get 7 without knowing that 20 was 6.

$\endgroup$
  • $\begingroup$ The relationship is linear. $\endgroup$ – paw88789 May 9 '17 at 15:00
  • 1
    $\begingroup$ I asked a co-worker also and he was like "why not just divide by 3 with no remainder" and I was just like ...oh. $\endgroup$ – Sam W May 9 '17 at 15:03
  • $\begingroup$ Either do what your coworker said, or $y(x) = \frac{x-2}3$. $\endgroup$ – M. Winter May 9 '17 at 15:06
1
$\begingroup$

Try $$f(x) = \frac{x-2}{3}$$ and plug input for $x$, then $f(x)$ will return output.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ This works, thank you! $\endgroup$ – Sam W May 9 '17 at 15:04

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.