-1

10,25,50,100,250,500,1000..... How to find above number series equation.

I need to generate the number pattern like above to plot it in my graph.

I tried like 2x, 2x, 2x + x / 2, 2x, 2x, ..... 2n, but I am unable to find a correct format of the equation. Can anyone help me?

bunbun
  • 2,595
  • 3
  • 34
  • 52

1 Answers1

1

Here is an expression in computer code (Python, to be precise). Here, n is the position of the number in your sequence, staring with 1. The result of this expression is the nth value in your sequence.

10 ** ((n+4)//3) * 2 ** ((n+4)%3) // 4

As you can see by the // 3 and % 3 in that expression, this works by dividing your sequence into groups of three: 25, 50, 100, 250, 500, 1000, etc. My expression calculates the last value in that group of three, which is a power of 10. Then my expression multiplies by an appropriate fractional factor, one of 1/4, 2/4, 4/4. That multiplication by a fraction is done by multiplying by the numerator, which is a power of 2, then dividing by 4.

Note that n+4 is used twice. Many programming languages, including Python, have the divmod function that does the // (integer division) and % (integer modulus) operations simultaneously. If you are using a function to calculate, using divmod could make the function easier to understand and perhaps slightly faster. Also note that I chose this expression since it is fairly easy to translate to other computing environments. If your environment does not have the // or % operation those can be done with the int or trunc or similar function. Ask if you need help translating my expression to another environment.

Printing the first 12 values of that sequence (n is 1 through 12) results in

10
25
50
100
250
500
1000
2500
5000
10000
25000
50000
Rory Daulton
  • 21,934
  • 6
  • 42
  • 50
  • You can use also bitshift like this `4 >> (n % 3)` for the second part – MBo Dec 13 '18 at 12:19
  • @MBo: If you change that to `4 >> ((n+1) % 3)` that works! Great work! I don't mind if you put that in your own answer. I have thought of another way to avoid negative numbers and will now add that to my answer. – Rory Daulton Dec 13 '18 at 16:22
  • No, I wasn't going to make an answer, yours is comprehensive – MBo Dec 13 '18 at 16:55