Explanation

539.Track a Value Through Compound Assignments

Easy
Starting from x, apply these updates in order — add k, multiply by 2, subtract 3, divide by 2 (keeping only the whole part), take the remainder after dividing by 7 — and return the value of x after each of the five steps. The assignment operatorAssignment OperatorThe = sign in code. It evaluates the right side and stores the result in the variable on the left; it is not an equation. replaces a variable's value with a new one. Compound assignmentCompound AssignmentShorthand such as x += 3, which means x = x + 3. Every arithmetic operator has one: +=, -=, *=, /=, %=. operators combine an arithmetic step with that replacement. Recording x after each step makes it visible that every update builds on the result of the previous one.

Example 1:

Input: x = 5, k = 3

Output: [8,16,13,6,6]

Example 2:

Input: x = 1, k = 1

Output: [2,4,1,0,0]

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ x ≤ 1000
  • ●1 ≤ k ≤ 1000

x =

5

k =

3