View Code of Problem 103

#include<stdio.h>
#include<malloc.h>
#include<string.h>
#include<math.h>



int isPrime(int n) {
	int temp = sqrt(n);
	for (int i = 2;i <= temp;i++) {
		if (n%i == 0)
			return 0;
	}
	return 1;
}

int main()
{
	int a, b;
	while (scanf("%d%d", &a, &b) != EOF) {
		int count = 0;
		for (int i = a;i <= b;i++) {
			if (isPrime(i))
				count++;
		}
		printf("%d\n", count);
	}
	

}

Double click to view unformatted code.


Back to problem 103