Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #include <time.h>
- #include "BigInt.h"
- #include "BIStack.h"
- #include <iostream>
- using namespace std;
- bool primetest(BigInt b) {
- bool flag = false;
- flag = b.isProbablePrime(1000);
- if(!flag)
- return false;
- return true;
- }
- bool easynotprime(BigInt b) {
- if(b % BigInt::two() == BigInt::zero()) return false;
- BigInt three = BigInt::two() + BigInt::one();
- BigInt five = three + BigInt::two();
- BigInt seven = five + BigInt::two();
- BigInt eleven = seven + three + BigInt::one();
- if(b % three == BigInt::zero() || b % five == BigInt::zero() || b % seven == BigInt::zero() || b % eleven == BigInt::zero())
- return false;
- else
- return true;
- }
- int main() {
- char line[256];
- BigInt b = -BigInt::one();
- b.generateRandom(40);
- if(b < BigInt::zero())
- b = BigInt::zero() - b;
- cout << b << '\n';
- while(!primetest(b)) {
- b += BigInt::one();
- while(!easynotprime(b))
- b += BigInt::one();
- }
- cout << b << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement