1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2012
Posts
1
Rep Power
0

I am trying to write a code to output a certain value (y) when given a value (x). It is something like as x increases by 1, y increases by the previous y value doubled. In other words, if x=2001 and y=32, when x=2002, y=64, when x=2003, y=128. How would I program something like this. Thanks.
2. It is something like..
You need to ask a specific question, and you also need to show the code that you have currently.
3. mathematically, given x0 and y0 you want to find y given x.

It's perhaps
y0 * 2 raised to the power of (x-x0)

x0 is 2001
y0 is 32

what is y when x is 2003?

32 * (2 raised to the power of (2003-2001))
32 * 4 is 128

The formula tests correctly.
4. No Profile Picture
Contributing User
Devshed Intermediate (1500 - 1999 posts)

Join Date
Feb 2004
Location
San Francisco Bay
Posts
1,939
Rep Power
1317
Originally Posted by DHulse94
It is something like as x increases by 1, y increases by the previous y value doubled.
It is something like y = y0*2**(x-x0).