What is the longest distance at which an aircraft can be visually identified?
The key piece of information here is the "Angular Resolution" of the naked eye.

Is called in this way because the key parameter is the perceived angle between two points when looking at them. Let's take 2 points that are distant 1 meter one from the other.

Let's then put them at a distance from your eyes, the angle you see between them can be computed as follows:



Image source

$angle\_in\_degrees = 2*atan(\frac{distance\_between\_them}{2*distance\_from\_you})*\frac{180}{\pi} $


if they are 10 meters from you, they will appear about 5.7° apart
at 100 meters from you, they will appear 0.57° apart
1000 meters, 0.057° apart


Note that two dots 10 meters apart and 100 meters from you will appear with the same 5.7° of the dots 1 meter apart and 10 meters from you: this is why, if you do not have other references, is nearly impossible to understand the distance from you of an object.

Now you are interested in reading something, in particular the aircraft number.

The naked eye cannot distinguish two points that appear less than 0.0128° apart (bright day, with no haze nor warm air distortion)

From what we see above, if the lettering is 1m tall, you could distinguish it at about 4 km. 
To actually read it, though, you will have to pick up the details, that will be much smaller: thik of distinguishing a "O" from a "D", you will have to notice that the left side is straight (or not), a detail much smaller than the total height of the letter and this will greatly reduce you maximum distance at which you can read.

Recognizing the livery instead is quite easier, as full portion of the aircraft will be painted, and in this case you only have to pick up the colours, not details of the shapes.

You could also distinguish the shape of on aircraft from a larger distance, given the much larger dimension of a full aircraft, but as for the letters, smaller details will not be recognizable until you get close enough, where "enough" depends on time of day, weather conditions and size of what you want to observe.