How to calculate: $2-2 | 3-1.5 | 4-1.25 | 5-1.125 ...$

153 Views Asked by At

I have a tricky programming problem.

I want to scale something in a program. When I scale it times 2 I need to multiply a variable with 2 to get a correct outcome. When i scale it times 3, I have to multiply this variable with 1.5. And so on and so on(as in the title). I don't know how I could calculate this although I thought about it quite a bit.

I hope this is the right kind of question for this SE :)

PS: I had no idea how to tag this.Please tell me if its wrong and an alternative.

1

There are 1 best solutions below

0
On BEST ANSWER

Maybe you are asking for a function which returns these values. I think $f(n) =1+2^{-n+2}$ should work.

So $f(2) = 2, f(3) = 1.5, f(4) = 1.25$ etc.