ZDIFFSQ2 - What is the next number in the sequence
Given a sequence of integers [s1 ... sn] the first difference of this sequence d1 is [s2-s1, s3-s2, s4-s3 ...]. Subsequent differences can be derived from the first difference, so if we number the elements in the first difference [d11 d12 d13 d14 ...] the second difference d2 is [d12-d11, d13-d12, d14-d13 ...].
For some sequences, the nth difference is zero.
The triangular numbers can be thought of in this way -
s = [1 3 6 10 15 ...]
d1 = [2 3 4 5 ...]
d2 = [1 1 1 1 ...]
d3 = [0 0 0 0 ...]
Given such a sequence, calculate the next three elements in the sequence.
Input
A single line of text featuring M (M<10) space separated integers
Output
A single line of text featuring 3 space separated integers
Example
Input: 15 32 57 90 131 180 Output: 237 302 375
Added by: | handee |
Date: | 2020-06-12 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |