![]() |
|
|
#23 | |
|
Nov 2003
22×5×373 Posts |
Quote:
If you know how to do the calculation, then a specialized program is not needed. Nor is it any faster. |
|
|
|
|
|
|
#24 | |
|
Jun 2003
Ottawa, Canada
3·17·23 Posts |
Quote:
I have now released v1.1 available from: http://gilchrist.ca/jeff/MprimeDigits New in v1.1:
As for Dr. Silverman's comments, I originally wrote this program for myself just to make it easier to calculate with 1 button push instead of several, but I figured others on the Internet in general would be interested as well so it is now available for anyone to use. In order to help people learn if they wish, I have now included the formula the program uses as a starting point for them instead of it being a complete black hole. |
|
|
|
|
|
|
#25 |
|
Jun 2003
Ottawa, Canada
3·17·23 Posts |
Well it is faster in the sense that with my program you can use a script to pass it multiple values to calculate at once, giving you all the results in probably the same amount of time it would take to use a hand calculator for one number.
|
|
|
|
|
|
#26 |
|
∂2ω=0
Sep 2002
República de California
19×613 Posts |
Using the unix/linux bc utility [or a decent electronic calculator with any form of a "log" function], it's trivial: start "bc -l" [the -l flag invokes floating-point mode], then
[your exponent here]*l(2)/l(10) ..and round up. The -1 subtracted from the 2^p in the real Mersenne number is nearly always ignorable if the the digit count is large - you'd only need to include it if the above result is really, really close to a whole number. ["How close" makes for a nice homework assignment.] Example: for p = 32582657, the above gives 9808357.095430986538..., which is not close to a whole number in the relevant sense, so we round confidently up and get 9808358 decimal digits for M44. |
|
|
|
|
|
#27 | |
|
Oct 2007
Manchester, UK
23×59 Posts |
Quote:
Edit: When finding the number of digits for a number such as 5^n*2^n - 1 though, the minus one does matter. Last fiddled with by lavalamp on 2008-09-03 at 17:30 |
|
|
|
|
|
|
#28 |
|
"Robert Gerbicz"
Oct 2005
Hungary
2·743 Posts |
For large inputs your program is still bad (see the picture).
My c solution for the problem, no trick, not using built in large math libraries: ( it should be good for p<10^40 ) Code:
#include <stdio.h>
#include <string.h>
int main() {
int A[40],B[100],R[141],carry,valid,i,j,L;
char input[64],w[101]="3010299956639811952137388947244930267681898814621085413104274611271081892744245094869272521181861720";
while(1) {
printf("Please input an exponent (at most 40 digits) : ");
scanf("%s",input);
L=strlen(input);
valid=1;
for(i=0;i<L;i++)
if((input[i]<'0')||(input[i]>'9')) valid=0;
if((valid==0)||(L>40)) printf("Invalid input!\n");
else break;
}
for(i=0;i<L;i++) A[i]=input[L-1-i]-'0';
for(i=0;i<100;i++) B[i]=w[99-i]-'0';
for(i=0;i<141;i++) R[i]=0;
// grammar school multiplication
for(i=0;i<L;i++)
for(j=0;j<100;j++) R[i+j]+=A[i]*B[j];
R[100]++;
carry=0;
for(i=0;i<=140;i++) {
carry+=R[i];
R[i]=carry%10;
carry/=10;
}
i=140;
while(R[i]==0) i--;
printf("The number of decimal digits of 2%c%s%c1 is ",'^',input,'-');
while(i>=100) printf("%d",R[i]),i--;
printf("\n");
return 0;
}
Last fiddled with by R. Gerbicz on 2008-09-03 at 23:55 |
|
|
|
|
|
#29 |
|
May 2008
3·5·73 Posts |
|
|
|
|
|
|
#30 |
|
"Nancy"
Aug 2002
Alexandria
2,467 Posts |
On a side note, if you want to do the (approximate) conversion with pencil and paper, a useful fact to remember is that
F12 has 1234 decimal digits. Conveniently, the leading digits of F12 are 104..., so 2^4096 is pretty close to 10^1233, and the estimate log(10)/log(2) ~= 4096/1233 = 3.3219... is reasonably accurate. From the continued fraction expansion the better fraction 2136/643 = 3.321928... can be found, but it's not as easy to remember. Alex |
|
|
|
|
|
#31 | |
|
Nov 2003
22×5×373 Posts |
Quote:
who doesn't know how to do the calculation need to know how many digits 2^p-1 has? |
|
|
|
|
|
|
#32 | |
|
Bamboozled!
"𒉺𒌌𒇷𒆷𒀭"
May 2003
Down not across
2×5,393 Posts |
Quote:
An adequate justification for wanting to know is idle curiosity. Paul |
|
|
|
|
|
|
#33 |
|
Nov 2003
164448 Posts |
|
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ten Billion Digits Mersenne Numbers | aketilander | Operation Billion Digits | 14 | 2021-02-27 07:14 |
| Mersenne Digits Curiosity | davar55 | Lounge | 11 | 2013-02-08 15:19 |
| Program to TF Mersenne numbers with more than 1 sextillion digits? | Stargate38 | Factoring | 24 | 2011-11-03 00:34 |
| Who is LL-ing a mersenne number > 100M digits? | joblack | LMH > 100M | 1 | 2009-10-08 12:31 |
| Digits of Pi in Mersenne Prime? | Unregistered | Miscellaneous Math | 3 | 2004-04-09 15:31 |