1. n=15
2. n=24
begin
input n;
while r > or = to 6 do
r = r - 6;
output r;
end
My question is - what can be said about 'n' if the output from this algorithm is 0?
Thanks
Oz
that's it,
if you are running a little subroutine,
and the program takes 24 as input data,
then the first run through the routine gives r=24-6=18, $\displaystyle r\ge 0$
second run gives r=18-6=12, $\displaystyle r\ge 0$
third run gives r=12-6=6, $\displaystyle r\ge 0$
fourth run gives r=6-6=0 $\displaystyle r\ge 0$
fifth run gives r=0-6=-6 $\displaystyle r\ge 0\$ no longer
whereas, if n=15
16-6=9
9-6=3
3-6=-3
When the algorithm stops, r will be -6 or -3 depending on the
initial value chosen, but only one of these routines generates an r=0.