Getting run time error for larger n and no output for smaller