A young girl counted in the following way on the fingers of her left hand. She started calling the thumb 1, the index finger 2, the middle finger 3, the ring finger 4, the little finger 5, then reversed direction calling the ring finger 6, the middle finger 7, the index finger 8, the thumb 9 then back to the index finger for 10, the middle finger for 11, and so on. She counted up to n (to be input by the user). She ended on her which finger?
Answer:
n = n % 8;
switch{
case 1: Thumb;
case 2 or 0 : Index
case 3 or 7 : Middle
case 4 or 6 : Ring
case 5 : Little
}