Back
Close

Sequential

Statement

 Goal

Find the Nth term in the given arithmetic or geometric sequence S.
Input
An integer N
A space-separated line of integers representing the first 6 numbers of the sequence S
Output
The Nth term of the sequence as an integer. Note that the sequence is 0-indexed!
Constraints
6 <= N <= 100
Nth term of sequence < 2^31
Example
Input
7
1 2 3 4 5 6
Output
8

Game modes
Fastest, Shortest, Reverse

Test cases
Simple Arithmetic Test
Input
7 1 2 3 4 5 6
Output
8

Simple Arithmetic Validator
Input
6 1 2 3 4 5 6
Output
7

Negative numbers Test
Input
7 -19 -15 -11 -7 -3 1
Output
9

Negative numbers Validator
Input
10 -10 -9 -8 -7 -6 -5
Output
0

Big N Test
Input
100 22 33 44 55 66 77
Output
1122

Big N Validator
Input
100 1000 2000 3000 4000 5000 6000
Output
101000

Simple Geometric Test
Input
10 1 3 9 27 81 243
Output
59049

Simple Geometric Validator
Input
9 1 2 4 8 16 32
Output
512

Negative Geometric Test
Input
11 5 -10 20 -40 80 -160
Output
-10240

Negative Geometric Validator
Input
7 -4 12 -36 108 -324 972
Output
8748

Decreasing Test
Input
8 -1 -2 -3 -4 -5 -6
Output
-9

Decreasing Validator
Input
10 4 2 0 -2 -4 -6
Output
-16

Identity Test
Input
10 2 2 2 2 2 2
Output
2

Identity Validator
Input
100 -1 -1 -1 -1 -1 -1
Output
-1

Decreasing Geometric Test
Input
6 700000000 70000000 7000000 700000 70000 7000
Output
700

Decreasing Geometric Validator
Input
10 3145728 786432 196608 49152 12288 3072
Output
3

Solution language

Solution

Stub generator input