This is final code for PF calculation and verified the same.