1. You will write 100 random integers from 1 to 10 on the blackboard. 
2. A student chooses one of the first 10 numbers and does NOT tell the instructor.
	If the number is 7, say, she counts 7 places along the list, notes the digit at the location,     
	and contiues the process. She records the LAST number that she encounters 
	on the list before leaving it.
		
A possible sequence is underlined on the list below :

3 4 7 8 2 3 7 5 6 1 6 4 6 5 7 8 3 1 5 3 10 7 9 2 3   so the recorded number is 9.

3. The instructor looks at the list and guesses the recorded number. How is this possible?

end[i_:1,list_:t,test_:T]:=
Module[{current=i,next},
If[test,Print[StringForm["at position `` we have ``",current,list[[current]]]]];
While[current+list[[current]]<=Length[list],
next=current+list[[current]];current=next;If[test,Print[StringForm["at position `` we have ``",current,list[[current]]]]]
];
If[test,Print["ends at ",list[[current]]]];
Return[list[[current]]]
]

end2[i_:1,list_:t,test_:T]:=
Module[{current=i,next,listout,listoutwithloc},
If[test,Print[StringForm["at position `` we have ``",current,list[[current]]]]];
listout={list[[current]]};listoutwithloc={{current,list[[current]]}};
While[current+list[[current]]<=Length[list],
next=current+list[[current]];current=next;If[test,Print[StringForm["at position `` we have ``",current,list[[current]]]]];listout=Join[listout,{list[[current]]}];listoutwithloc=Flatten[Join[{listoutwithloc},{{{current,list[[current]]}}}],1];
];
If[test,Print["ends at ",list[[current]]]];

Print[listout];Print["with location included: ",listoutwithloc];
Return[list[[current]]]
]

EXAMPLE :

t={3,4,7,8,2,3,7,5,6,1,6,4,6,5,7,8,3,1,5,3,10,7,9,2,3}

Length[t]

end2[3,t]

end2[3,t]

end2[1,t]

end2[2,t]

end2[4,t]

end2[5,t]

ENTER YOUR LIST OF 100 (rather than 25) RANDOM NUMBERS (BETWEEN 1 AND 10) HERE:

t={...}

end2[1,t]

IN CLASS PRESENTATION ENDS HERE (PART 1)

NN=Length[t];(*t=Table[Random[Integer,{1,10}],{i,1,NN}]*);Print[t];

tx=Table[{i,end[i,t,F]},{i,1,10}];Print["(start,end) pairs:  ",tx];Print[Transpose[tx]];(*Print[Transpose[tx][[2]]];*)Print["absolute frequencies for the ending numbers: (what, how-many-times)=",Tally[Transpose[tx][[2]]]]

IN CLASS PRESENTATION ENDS HERE (PART 2)

RANDOM EXAMPLES (PART 3):

NN=100;t=Table[Random[Integer,{1,10}],{i,1,NN}];Print[t];

tx=Table[{i,end[i,t,F]},{i,1,10}];Print["(start,end) pairs:  ",tx];Print[Transpose[tx]];(*Print[Transpose[tx][[2]]];*)Print["absolute frequencies for the ending numbers: (what, how-many-times)=",Tally[Transpose[tx][[2]]]]

NN=100;t=Table[Random[Integer,{1,10}],{i,1,NN}];Print[t];

tx=Table[{i,end[i,t,F]},{i,1,10}];Print["(start,end) pairs:  ",tx];Print[Transpose[tx]];(*Print[Transpose[tx][[2]]];*)Print["absolute frequencies for the ending numbers: (what, how-many-times)=",Tally[Transpose[tx][[2]]]]

end2[i_:1,list_:t,test_:T]:=
Module[{current=i,next,listout,listoutwithloc},
If[test,Print[StringForm["at position `` we have ``",current,list[[current]]]]];
listout={list[[current]]};listoutwithloc={{current,list[[current]]}};
While[current+list[[current]]<=Length[list],
next=current+list[[current]];current=next;If[test,Print[StringForm["at position `` we have ``",current,list[[current]]]]];listout=Join[listout,{list[[current]]}];listoutwithloc=Flatten[Join[{listoutwithloc},{{{current,list[[current]]}}}],1];
];
If[test,Print["ends at ",list[[current]]]];

Print[listout];Print["with location included: ",listoutwithloc];
Return[list[[current]]]
]

end2[1]

RANDOM EXAMPLES ENDS HERE (PART 3)