Quick question

Can I have sex without a condom but be on the pill? Would that prevent pregnancy