Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 10 Weeks Ago, 4 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Hi! It's me again. So could you please write out mpz_legendre, mpz_powm_ui, mpz_gcd, and mpz_sqrtrem in a normal way without directly using the gmp files? The other codes are totally fine. I am so sorry about the inconvenience. But thanks for helping me!!!! :)
Â
#include <gmpxx.h>#include <vector>#include <cmath>#include <iostream>// Constants// The optimal smoothness bound is exp((0.5 + o(1)) * sqrt(log(n)*log(log(n)))).const int SMOOTH_BOUND = 500;const int TRIAL_BOUND = 400;const int SIEVE_CHUNK = 60;const bool DEBUG = true;void *_Unwind_Resume;void *__gxx_personality_v0;typedef std::vector<int> int_vector;typedef std::vector<int_vector> matrix;typedef std::vector<mpz_class> mpz_vector;template <typename T> // Takes int_vector or mpz_vectorvoid print_vector(const T &x){for (size_t i = 0; i<x.size(); i++)std::cout << x[i] << ", ";std::cout << '\n';}// Sloppy coding// Return a list of primesint_vector eratosthenes(int bound){int_vector primes;std::vector<bool> A(bound, 1);A[0] = 0; A[1] = 0; // 0 and 1 aren't primefor (int i = 2; i<sqrt(bound); i++){if (A[i]){for (int j = i*i; j <= bound; j += i)A[j] = 0;}}for (int i = 0; i<bound; i++){if (A[i])primes.push_back(i);}return primes;}// Return a vector of a number's factors (ex. [0, 1, 2, 0]) and a boolean of// whether it's smooth or nottypedef std::pair<int_vector, bool> vb_pair;vb_pair factor_smooth(mpz_class n, const mpz_vector &factor_base){// Each item in factors corresponds to number in factor base