Prime number or not in Pascal

CodeChef: Practical coding for everyone this is the question which was asked yesterday in a contest by niit university. My code is:
CodeChef: Practical coding for everyone

What is the error in this sum?I tried all variations probably but did not get AC.