# Simple discrete math question

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.

• The relationship is linear. – paw88789 May 9 '17 at 15:00
• 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. – Sam W May 9 '17 at 15:03
• Either do what your coworker said, or $y(x) = \frac{x-2}3$. – M. Winter May 9 '17 at 15:06

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