# Finding the algorithm that's right for you.

• 02-02-2002
sean
Finding the algorithm that's right for you.
1 2 3 4 5 6 7 8 9 10
1 2 4 8 16 32 64 128 256 512

I need an equation that takes a number from the top row as it's only variable, and produces the corresponding number on the bottom. You can also move them around, like have 0 above the 2 or something, but just tell me which direction you moved which bar how far. I just need a starting point. i tried finding the differences but it just turns into circular logic.
• 02-02-2002
Salem

0 1 2 3 4 5 6 7 8 9 10
1 2 4 8 16 32 64 128 256 512

Then it's just pow(2,n)

Two, to the power of the number on the top row, gives you the number on the bottom row
• 02-02-2002
SilentStrike
A post in straight C from me... don't get these so often :). It's a simple function you want.

Code:

```#include <stdio.h> int main(int argc, char *argv[]) {   for (int i = 1; i < 11; i++) {     printf("Input is %i, output is is %i \n", i, 1 << (i - 1));   }   getchar();   return 0; }```
• 02-03-2002
sean
The annoying thing is, as soon as I logged off after posting this, I figured it out. Murphy's Law I guess.