x = 1,2,3,4,5... y = 1,4,7,10,13...
I need to write a function
$f(x_n) = y_n$
I found that if I
- take a number from x
- double it
- subtract 2
- add the result to the original number
- I get the corresponding number from y
Here's what I have so far (it's in ruby code), it works but is there a better way of doing it.
def f(x) if x > 1 return x + ((2 * x) - 2) else return 1 end end y = f(x)