And why are you dividing it and comparing it with "y"?
In for(i=1;(term/sum)*100<=y;i++) you have done like(term/sum) which is 0/0 which is not valid mathematical operation.
if you got the answer ........... please share it.........
This is a very complex problem man............
Separate names with a comma.