#include <stdio.h> #include <string.h> void main() { int a, b; while (scanf("%d %d", &a, &b) != EOF) { int sum = 0; if (a>b) { int temp = a; a = b; b = temp; } for (int i = a + 1; i < b; i++) { if (i == 1) { continue; } int flag = 1; for (int j = 2; j < i; j++) { if (i%j == 0) { flag = 0; break; } } if (flag) { sum += i; } } printf("%d\n", sum); } } |
Double click to view unformatted code.