Prime decomposer ruby implementation