1. An integrated circuit comprising: a resistance changing memory element; and a circuit configured to program the memory element by iteratively applying a variable program pulse to the memory element until a resistance of the memory element crosses a first reference resistance, the variable program pulse adjusted for each iteration such that the resistance of the memory element approaches the first reference resistance.