The eyes of a magician are blindfolded while a person $A$ from the audience arranges $n$ identical coins in a row, some are heads and the others are tails. The assistant of the magician asks $A$ to write an integer between $1$ and $n$ inclusive and to show it to the audience. Having seen the number, the assistant chooses a coin and turns it to the other side (so if it was heads it becomes tails and vice versa) and does not touch anything else. Afterwards, the bandages are removed from the magician, he sees the sequence and guesses the written number by $A$. For which $n$ is this possible?
HIDE: Spoiler hint The original formulation asks: a) Show that if $n$ is possible, so is $2n$; b) Show that only powers of $2$ are possible; I have omitted this from the above formulation, for the reader's interest.Problem
Source: Bulgaria EGMO TST 2016 Day 1 Problem 3
Tags: combinatorics, Magician, induction, logic