Implementation of a quantum algorithm on a nuclear magnetic resonance quantum computer