c - Prime numbers using Interface -
how write code prime number generator using specified interface.
i think asked.
int isprime(int i) { int j; if(i == 1 || == 2) return 1; if(i % 2 == 0) return 0; (j = 3; j < sqrt(n); j += 2) if (i % j == 0) return 0; return 1; } void generator(int start, int end) { int i; if(start > end) { int temp = start; start = end; end = start; } (i = start; i<=end; i++) if(isprime(i)) printf("%d\n", i); } int main() { generator(7900, 7920); return 0; }
Comments
Post a Comment