Guest User

Untitled

a guest
Nov 17th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. unsigned int gcd(unsigned int a, unsigned int b) {
  4. unsigned int t;
  5. while (b != 0) {
  6. t = a;
  7. a = b;
  8. b = t % b;
  9. }
  10. return a;
  11. }
  12.  
  13. int main(int argc, char *argv)
  14. {
  15. // x+y=n
  16. unsigned int x, y, n;
  17.  
  18. // This number is prime:
  19. n = 104729;
  20.  
  21. for (x = 1; x < n; x++)
  22. {
  23. y = n - x;
  24. if (gcd(x, y) != 1)
  25. {
  26. printf("Not Prime: %un", n);
  27. break;
  28. }
  29. }
  30.  
  31. if (x == n)
  32. {
  33. printf("Prime: %un", n);
  34. }
  35.  
  36. return 0;
  37. }
Add Comment
Please, Sign In to add comment