User blog comment:Coreilly301/Infinite Power With Equivalent Exchange/@comment-1757231-20140418145634

A little more efficient version.