Added Petre's convoluted algorithm.