confused at stupid errors

Look at the Estimate_A function, why the values of num will changed while I did not change it anyway......