View Code of Problem 103

#include<stdio.h>
#include<math.h>
int sushu(int n){
  int i;
  for(i=2;i<=sqrt(n);i++)
	  if(n%i==0)
		  return 0;
	  return 1;
}
int main(){
	long int a,b,i,rich;
	while(scanf("%ld%ld",&a,&b)!=EOF)
	{
		rich=0;
		for(i=a;i<=b;i++)
		{
			if(sushu(i))
			  rich++;
		}
		printf("%ld\n",rich);		
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 103