fork(2) download
  1. #include <stdio.h>
  2.  
  3. int checkP (int n)
  4. {
  5. for (int i=2; i<n; i++)
  6. if(n%i==0)
  7. return (0);
  8. return (1);
  9. }
  10.  
  11. int nextP (int n)
  12. {
  13. do
  14. n++;
  15. while (!checkP(n));
  16. return n;
  17. }
  18.  
  19. int main ()
  20. {
  21. int x = 34; //user input
  22. for (int i = 2; i < x - 1; i = nextP(i))
  23. {
  24. if (checkP(x - i)) {
  25. printf ("\n %d + %d", i, x-i);
  26. }
  27. }
  28. }
Success #stdin #stdout 0s 4580KB
stdin
Standard input is empty
stdout
 3 + 31
 5 + 29
 11 + 23
 17 + 17
 23 + 11
 29 + 5
 31 + 3