Implement divisor_sigma function

rebase of #7849