> even if it is not divisible it still produces the results

I thought it was supposed to produce results if it is not divisible. It's if it IS divisible that the number isn't valid.
What number did you enter?
After cin>>x you could try displaying the number entered as a check that x contains what you're expecting.

Why is your loop variable i a double?