Update alg3.h

Added variable resetting within the loop