Your program runs forever on n=1. Why?