Algorithm for finding the next number in a sequence of numbers?

I have the following sequence of numbers:

2 5 6 20 18 80 54 320 162 1280

I just can't find the next next number or algorithm to calculate it.

Any clues?

+3
source share
8 answers

The next number 486.

The sequence is * 3, * 4.

Each odd index is multiplied by 4:

5 20 80 320 1280

Each even index is multiplied by 3:

2 6 18 54 162

So the 486following number. :-)

+11
source

Next 486

Just wolframalpha

Mathematica Output: {2, 5, 6, 20, 18, 80, 54, 320, 162, 1280, 486, 5120, 1458, 20480, 4374}

and here is the recurrence relation that it gives:

a(n+4) = 7*a(n+2)-12*a(n)
+7
source

. , , , - , . , , . - , , . , , - , , - , , .

, . .: -)

+4

Java, :

/**
 * @author mpieciukiewicz
 */
public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        for (int p=0; p<11; p++) {
            System.out.println(p+":"+number(p));
        }
    }

    private int calculate(int base, int multiplier, int power) {
        int result = base;
        for (int p=0; p<power; p++) {
            result = result * multiplier;
        }
        return result;
    }

    private int number(int index) {
       int half = index / 2;
       int number;
       if (index%2 == 0) {
           number = calculate(2, 3, half);
       } else {
           number = calculate(5, 4, half);
       }
       return number;
    }
}

:

0:2
1:5
2:6
3:20
4:18
5:80
6:54
7:320
8:162
9:1280
10:486

, : 468.

+3

:

a1=2
a2=4
a3=a1*3
a4=a2*4
a5=a3*3
a6=a4*4

:

a(2k+1)=a(2k-1)*3
a(2k)=a(2k-2)*4
+1

51, 128 - . , 16,125.

0

486

2 2 5 6 20 18 80 54 320 162 1280

2 6 18 54 162 5 20 80 320 1280

1- 3x 4- - 4 x 3x 162, - 4x 1280

0

Source: https://habr.com/ru/post/1786102/


All Articles