An easy puzzle for beginners:
You are in front of a computer which, upon your input, will produce a sequence of numbers. Your task is to discover which logic was used to program the computer.
Sitting in front of the computer, you type: 7. The computer replies with the sequence: 5, 4, 4, 4, and then 4 all along.
Then you type 6. The computer replies with: 3, 5, 4, 4, 4, and then 4 all along.
Pensive, you type 42. Computer's reply: 8, 5, 4, 4, 4, and then 4 all along again.
You try different numbers, and notice that all sequences eventually go with 4 repeated endlessly.
What is the algorithm used?