mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2008-08-31, 01:05   #1
Jeff Gilchrist
 
Jeff Gilchrist's Avatar
 
Jun 2003
Ottawa, Canada

3·17·23 Posts
Lightbulb Mersenne Prime # of Digits Calculator

Most of you here already know how to calculate this but for those of you that don't, I threw together a quick program that will calculate the number of decimal digits in a specified Mersenne number (2^p-1).

There are Windows binaries available (GUI and command line), plus source code for the command line version to compile on Linux/Unix systems.

You can download the software from:
http://gilchrist.ca/jeff/MprimeDigits/

Jeff.
Attached Thumbnails
Click image for larger version

Name:	MprimeDigits.gif
Views:	354
Size:	12.0 KB
ID:	2653  
Jeff Gilchrist is offline   Reply With Quote
Old 2008-08-31, 02:58   #2
Uncwilly
6809 > 6502
 
Uncwilly's Avatar
 
"""""""""""""""""""
Aug 2003
101×103 Posts

3×47×71 Posts
Default

Great idea. Maybe someone can throw together a Java version of this.

Last fiddled with by Uncwilly on 2008-08-31 at 02:58
Uncwilly is offline   Reply With Quote
Old 2008-08-31, 03:18   #3
retina
Undefined
 
retina's Avatar
 
"The unspeakable one"
Jun 2006
My evil lair

142168 Posts
Default

Also, maybe do the reverse, allow the user to enter the decimal digits and compute the binary equivalent.
retina is online now   Reply With Quote
Old 2008-08-31, 07:30   #4
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

149410 Posts
Default

Quote:
Originally Posted by Jeff Gilchrist View Post
I threw together a quick program that will calculate the number of decimal digits in a specified Mersenne number (2^p-1).
Your program is broken:
Code:
Mersenne Prime # Digits Calculator v1.0    [Aug. 30, 2008]
by Jeff Gilchrist (http://gilchrist.ca/jeff/)

This program will calculate the number of decimal digits in
the specified Mersenne number 2^p-1.

Enter the value of p to calculate: 100000000000000000039

Number of decimal digits in 2^7766279631452241959-1 is: 2337883123781333504
R. Gerbicz is offline   Reply With Quote
Old 2008-08-31, 07:43   #5
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

17×563 Posts
Default

This tool can also be used (with minor modifications) to calculate number of Mb in a hard-drive-maker's Terabyte and/or Gigabyte, and maybe even number of millions of bytes in a Mb. Just don't take my comment too seriously. It is a useful tool.
Batalov is offline   Reply With Quote
Old 2008-08-31, 08:08   #6
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

17·563 Posts
Default

Quote:
Originally Posted by Uncwilly View Post
Great idea. Maybe someone can throw together a Java version of this.
Java? Why waste Java for that. Javascript will do. Just drop this code in a "digits.html" file on your desktop and click on it
Code:
<HTML><HEAD><TITLE>Conversion Exponent/Digits JavaScript</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1251">
<SCRIPT language=JavaScript>
<!--
function DigitsExp(){document.convert.Digits.value = document.convert.Exponent.value*0.301029995664;}
function ExpDigits(){document.convert.Exponent.value = document.convert.Digits.value/0.301029995664;}
//-->
</SCRIPT>
<META content="MSHTML 6.00.6000.16705" name=GENERATOR></HEAD>
<BODY text=#fExpDigitsc03 vLink=#ffffff link=#ffffff bgColor=#000000>
<CENTER>
<TABLE cellPadding=5 border=1><TBODY><TR><TD>
<FORM name=convert>
<H1>Mersenne Prime Digits</H1>
<INPUT onblur=DigitsExp();  onfocus="document.convert.Digits.value='';" maxLength=10 size=10 value=0 name=Exponent>
<FONT size=+2>Exponent</FONT> 
<INPUT onclick=DigitsExp(); type=button value=">>"> <INPUT onclick=ExpDigits(); type=button value="<<"> 
<FONT size=+2>Digits</FONT>
<INPUT onblur=ExpDigits();  onfocus="document.convert.Exponent.value='';" maxLength=10 size=10 name=Digits> </FORM></TR></TBODY>
</TABLE>
</BODY>
</HTML>
--Serge
Attached Files
File Type: zip digits.zip (648 Bytes, 247 views)
Batalov is offline   Reply With Quote
Old 2008-08-31, 15:40   #7
dsouza123
 
dsouza123's Avatar
 
Sep 2002

2×331 Posts
Default

A Delphi (Pascal) Windows console mode version.
It agrees with a ubasic version for the first 18 digits
after that it just it puts zeros, at least with a 20 digit p.
With p <= 18 digits the results agree with the numbers I've tested.

Delphi :

Enter the value of p in 2^p - 1
(with p maximum 18 digits, for good results) : 100000000000000000039
2^100000000000000000000 - 1 has 30102999566398119500 decimal digits.

UBasic :

Enter the value of p in 2^p - 1
(with p maximum xx digits, for good results) : ? 100000000000000000039
2^ 100000000000000000039 - 1 has 30102999566398119532 decimal digits.

Code:
Program BiDecDig;
var
  power2  : extended;
  power10 : extended;
  x       : extended;
  y       : extended;
  z       : extended;
  s       : string;
  
begin
  power2  := 32582657.0; // The example value used in the 1st post in the thread

  writeln('Enter the value of p in 2^p - 1');
  write  ('(with p maximum 18 digits, for good results) : ');
  readln(power2);

  x := ln(2.0);
  y := ln(10.0);
  z := ((x/y) * power2) + 1.0;
  power10 := int(z);
  writeln('2^',power2:0:0,' - 1 has ',power10:0:0,' decimal digits.');
  readln(s);
end.
The ubasic source code.
Code:
  100   print "Enter the value of p in 2^p - 1"
  110   input "(with p maximum xx digits, for good results) : ";Power2
  120   X=log(2)
  140   Y=log(10)
  160   Z=((X/Y)*Power2)+1.0
  180   Power10=fix(Z)
  200   print "2^";Power2;"- 1 has";Power10;"decimal digits."
The UBasic version may be accurate to hundreds of digits but
I don't have any way to test it.

Delphi source and executable and UBasic source
are in the attachment BiDecDig.zip
Attached Files
File Type: zip BiDecDig.zip (9.5 KB, 165 views)

Last fiddled with by dsouza123 on 2008-08-31 at 15:41
dsouza123 is offline   Reply With Quote
Old 2008-09-01, 00:56   #8
Jeff Gilchrist
 
Jeff Gilchrist's Avatar
 
Jun 2003
Ottawa, Canada

3×17×23 Posts
Default

Quote:
Originally Posted by R. Gerbicz View Post
Your program is broken:
It is not really broken, more that it only supports 64bit integers so the largest p value you can enter is: 18446744073709551616

Luckily I didn't leave it as 32bit ints.

Are you trying to figure out what kind of primes your great grandchildren will be testing?

Jeff.
Jeff Gilchrist is offline   Reply With Quote
Old 2008-09-01, 02:04   #9
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

957110 Posts
Default

I think what we need now is a parody on the "programmer's progression" joke (the Hello World program progression from Basic to Fortan, Algol, Pascal, Cobol, PL/SQL, Ada and brainf*ck ... and beyond)

Who is game to write the BF implementation?
Batalov is offline   Reply With Quote
Old 2008-09-01, 13:11   #10
davieddy
 
davieddy's Avatar
 
"Lucan"
Dec 2006
England

194A16 Posts
Default

Personally speaking, a conversion factor of log102
serves my purposes well enough.
davieddy is offline   Reply With Quote
Old 2008-09-01, 15:43   #11
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

2·32·83 Posts
Default

Quote:
Originally Posted by Jeff Gilchrist View Post
It is not really broken, more that it only supports 64bit integers so the largest p value you can enter is: 18446744073709551616

Luckily I didn't leave it as 32bit ints.

Are you trying to figure out what kind of primes your great grandchildren will be testing?

Jeff.
There are numbers less than 2^64 for which your program is bad:
for example: p=28505944177 (this p is prime)
or for p=198096465 (this p is composite) gives bad number of digits for 2^p-1

Last fiddled with by R. Gerbicz on 2008-09-01 at 15:44
R. Gerbicz is offline   Reply With Quote
Reply

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

All times are UTC. The time now is 22:20.


Fri Oct 22 22:20:08 UTC 2021 up 91 days, 16:49, 0 users, load averages: 2.06, 2.03, 2.41

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.