Chef is at x=0.
1-jump: he will move from x -> x + 1
2-jump: he will move from x -> x + 2
3-jump: he will move from x -> x + 3
He will perform a lot of jumps in such a sequence: 1-jump, 2-jump, 3-jump, 1-jump, 2-jump, 3-jump, 1-jump, and so on.
Given an integer 0 ≤ a ≤ 1018, find will he ever arrive at a.
In one sequence of 1-jump, 2-jump and 3-jump, he moves from x -> x + 6. So, if intermediate jumps are removed for a minute, x will always be a multiple of 6. Now, if we consider intermediate jumps, we will also consider points of form 6*k - 3, 6*k - 5.
@vivekshah1801 it took me 5 minutes to find the bug in your code. The bug is that the problem does not have any test cases!! You just have to take the number and show the output. I took care of this when I coded my solution but don’t know why it took so much time to find it in your code, lol.