The sequence of segmented numbers or prime numbers of measurement (OEIS A002048) is the sequence of numbers such that each member is the smallest positive (greater than zero) number that can't be made of a sum of earlier consecutive numbers, with a(0) = 1
.
Example
To calculate a(7)
we first calculate a(0->6) = [1, 2, 4, 5, 8, 10, 14]
. we then start from zero and go through numbers until we find one that is not the sum of one or more consecutive numbers in the sequence.
1 = 1
2 = 2
3 = 1 + 2
4 = 4
5 = 5
6 = 2 + 4
7 = 1 + 2 + 4
8 = 8
9 = 4 + 5
10 = 10
11 = 2 + 4 + 5
12 = 1 + 2 + 4 + 5
13 = 5 + 8
14 = 14
15 = ????
Since fifteen cannot be made by summing any consecutive subsequence and every number smaller can be fifteen is the next number in the sequence. a(7) = 15
Task
Your task is to take a number (via standard methods) and output the nth term in this sequence (via standard output methods). This is code-golf and you will be scored as such.
Test Cases
0 -> 1
1 -> 2
2 -> 4
3 -> 5
4 -> 8
5 -> 10
6 -> 14
7 -> 15
8 -> 16
9 -> 21