RigUp interview question

Prime numbers, pivot array, SQL problem