Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <time.h>
  6.  
  7. #include "BigInt.h"
  8. #include "BIStack.h"
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. bool primetest(BigInt b) {
  14. bool flag = false;
  15. flag = b.isProbablePrime(1000);
  16. if(!flag)
  17. return false;
  18. return true;
  19. }
  20.  
  21. bool easynotprime(BigInt b) {
  22. if(b % BigInt::two() == BigInt::zero()) return false;
  23. BigInt three = BigInt::two() + BigInt::one();
  24. BigInt five = three + BigInt::two();
  25. BigInt seven = five + BigInt::two();
  26. BigInt eleven = seven + three + BigInt::one();
  27. if(b % three == BigInt::zero() || b % five == BigInt::zero() || b % seven == BigInt::zero() || b % eleven == BigInt::zero())
  28. return false;
  29. else
  30. return true;
  31. }
  32.  
  33. int main() {
  34. char line[256];
  35. BigInt b = -BigInt::one();
  36.  
  37. b.generateRandom(40);
  38. if(b < BigInt::zero())
  39. b = BigInt::zero() - b;
  40. cout << b << '\n';
  41. while(!primetest(b)) {
  42. b += BigInt::one();
  43. while(!easynotprime(b))
  44. b += BigInt::one();
  45. }
  46.  
  47.  
  48. cout << b << '\n';
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement