Generalized Arithmetic Progression Free Sequence
For given two positive integers a and b let's construct the sequence x[1], x[2], ... by the following rules. For k=1 we put x[1]=1. Now let k >= 2. Then x[k] is the least positive integer such that the following two conditions hold - x[k] > x[k - 1]; - for all i, j we have x[k] is not equal to a * x[i] - b * x[j]. You need to find the first n terms of this sequence. Remark. Let a=2 and b=1. Th
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start