“Why am I getting repeating numbers for the array x as an output for the following piece of script?”
You are not getting the same values repeating in x. You just confused how values are displayed with the values stored in memory. Try printing the values of x with e.g. two decimal places. Then tell us what you see.