In pattern we want n number of stars in first and last row but in my output n+1 stars in first and last where i had done mistake