hey..everything is allright until if(n%x==0)
all u got to do is:
its more simpler...according to me...
the mistake was....inside the for loop...u are increasing the counter...
but u are checking for the prime number before the whole loop executes....
u can obtain the value of the counter only after it checks for the remainder of each and every number until the input number...
i think it is the mistake,....i have tried my best to explain...if anything i said was wrong...please correct me....