Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Reversing a Formula

1. ## Reversing a Formula

I'm currently using the following function to find \$a based on \$L:

PHP Code:
``` function XP(\$L) {   \$a=0;   for(\$x=1; \$x<\$L; \$x++) {     \$a += floor(\$x+300*pow(2, (\$x/7)));   }   return floor(\$a/4); }  ```
What I would like to do is find L based on a. For example, \$a = 83 when \$L = 2 and \$a = 174 when \$L = 3. I would like to instead input a value anywhere from 83-173 and have 2 returned.

Any suggestions would be greatly appreciated.

• Originally Posted by coolcamo8642
I'm currently using the following function to find \$a based on \$L:

PHP Code:
``` function XP(\$L) {   \$a=0;   for(\$x=1; \$x<\$L; \$x++) {     \$a += floor(\$x+300*pow(2, (\$x/7)));   }   return floor(\$a/4); }  ```
What I would like to do is find L based on a. For example, \$a = 83 when \$L = 2 and \$a = 174 when \$L = 3. I would like to instead input a value anywhere from 83-173 and have 2 returned.

Any suggestions would be greatly appreciated.
PHP Code:
``` function XPI(\$a){    \$x = 1;    while(\$a >= XP(\$x)){       \$x++;    }    return (\$x-1); }  ```
regards

• ## Users who have thanked oesxyl for this post:

coolcamo8642 (05-08-2008)

• Your code is absolute perfection for what I was trying to achieve. Thank you very much.

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•