a huge integer power 3 power n
Thomas Lover
mailbidonjustice at gmail.com
Thu Aug 25 09:08:53 UTC 2016
Hi !
I want to make this operation below with GMP ! And I have been trying for 10 days now without any success. So, I need help!
The user enters an integer called “n”. Then I need to have a number which is 3 power n.
Then I have to power a huge integer that has 1000 digits with 3^n.
Here is my actual program and my compiling code line: g++ -o mills1 mills1.cpp -lgmp -lgmpxx -std=c++11
I just don’t know how to declare this 1000 digits integer and I don’t know how to power it. And I don’t know the variable type of “p" at the end of the program.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <math.h>
#include <iostream>
#include <gmpxx.h>
#include <gmp.h>
using namespace std;
int main()
{
clock_t start;
start = clock();
mpz_clears;
mpf_clears;
mpz_class p,trois;
p=1;trois=3;
int n;
cout << “Enter a small integer between 1 and 20";
cin >> n;
mpz_pow_ui(p.get_mpz_t(),trois.get_mpz_t(),n);
cout << "3^n=" << p;
I NEED HERE TO DECLARE A INTEGER WITH 1000 DIGITS AND TO POWER IT WITH “p”.
start = clock() - start;
cout<<"le temps de calcul est "<<start;
cout<<"le nombre premier est "<<a;
mpz_clears;
mpf_clears;
return 0;
}
Thank you for any help !
Thomas Lover
http://www.energyistheglobalcurreny.org/
Save your world, then save the world or do both.
Delete maximum of mails, it's polluting.
thomaslover at ntymail.com
+918524959404, Auroville, India
More information about the gmp-discuss
mailing list