Solution:
Barbara manages to say the number n within 50 moves (in fact, at most 8 are needed), regardless of Alberto's strategy, if and only if n is a multiple of 6.
Indeed, suppose that n is a multiple of 6. Then we have that:
- if at a certain step Alberto chooses an even number, at the next step Barbara can choose 2, at which point Alberto can only play 1, 2, or 3, and in any case at the next step Barbara will be able to say n;
- if at a certain step Alberto chooses an odd number d, at the next step Barbara can choose 3d, at which point Alberto either plays an even number (falling into the previous case) or leaves 3d unchanged. At this point Barbara chooses the number 3, at which Alberto can only play 2, 3, or 4. If he plays 2 or 4 he loses because they are even numbers, if he plays 3 he loses because at the next step Barbara plays n.
Now suppose that n is not a multiple of 6. Then Alberto can always play a number that is not a multiple or divisor of n, thus preventing Barbara from winning on the next move. One possible strategy for Alberto is the following.
- At the first step he chooses n+1.
- When Barbara returns a number a>n, Alberto examines a and a+1. Since n>1, at least one of the two numbers is not a multiple of n and can therefore be played.
- When Barbara returns a number b<n, Alberto examines b−1, b, and b+1. Being three consecutive numbers, at least one will be even and at least one (possibly the same one) will be divisible by 3. Then n cannot be simultaneously divisible by b−1, b, and b+1, because otherwise it would be divisible by 6, which is against our assumption. Hence in this case too at least one of the three numbers can be played "safely" by Alberto.