Advertisement
GeeckoDev

pe27

Sep 10th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int isPrime(int n)
  4. {
  5.     if (n < 2) return 0;
  6.     int i, sqrt_n = sqrt(n);
  7.     for (i=2; i<=sqrt_n; i++) if (n%i == 0) return 0;
  8.     return 1;
  9. }
  10.  
  11.  
  12. int main()
  13. {
  14.     int a, b, n, max = 0, product;
  15.     for (a = -999; a < 1000; a++)
  16.     {
  17.         for (b = -999; b < 1000; b++)
  18.         {
  19.             for (n=0; isPrime(n*n+a*n+b); n++);
  20.             if (n > max) max = n, product = a*b;
  21.         }
  22.     }
  23.     printf("%d\n",product);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement