mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Miscellaneous Math (https://www.mersenneforum.org/forumdisplay.php?f=56)
-   -   Challenge (https://www.mersenneforum.org/showthread.php?t=12289)

Dougal 2009-08-18 20:10

yes but when you get up to exponents around 40 million you will have lots of exponents "likely" to give a prime.and what about the exponents that arent likely to give a prime but still do,do you want to just forget about these just because according to you,they arent "likely" to be prime?

science_man_88 2009-08-18 20:12

get me a list of primes higher than that and we might try a few lol
also if you don't want to I have a prime finder I can get to for me lol

science_man_88 2009-08-18 20:13

No but people can fill the gaps later

Dougal 2009-08-18 20:14

well if you have one,why would i want to do your work for you?

science_man_88 2009-08-18 20:17

also if excel isn't lying to me just over half of all mersennes found to date have digit # 's dividable by 3

science_man_88 2009-08-18 20:18

I'll give you the credit

science_man_88 2009-08-18 20:20

actually maybe by computer is better I bet they have a more accurate log2(3) value if I can get that function to work last time it didn't

science_man_88 2009-08-18 20:24

anyone got a C compiler especially C++ builder ? I'll even pre-make the rest of the needed code for you.

flouran 2009-08-18 20:40

[QUOTE=science_man_88;186397]anyone got a C compiler especially C++ builder ? I'll even pre-make the rest of the needed code for you.[/QUOTE]

I wouldn't trust your trivial and meaningless code.

science_man_88 2009-08-18 20:44

first it was originally made by someone else someone who helped me on bytes.com forum so talk to them not me if you don't trust it.

science_man_88 2009-08-18 20:47

Firstly it was written with the help of bytes.com forum -C section secondly if we can get a c99 function from math.h to work we can use it to find what I'm guessing to be about half of all mersenne primes.


#include <stdlib.h>
#include <math.h>
#include <stdio.h>
static int isPrime(int n) {
int i, inc= 2;
if (n == 2 || n == 3) return 1;
if (n%2 == 0 || n%3 == 0) return 0;
for (i= 5; i*i <= n; i+= inc, inc= 6-inc)
if (!(n%i)) return 0;
return 1;
}
int main() {
int file = 0;
unsigned int i;
FILE *fp;
fp=fopen("sample.txt","w");
for (i=3; i < 4294967295; i=i+2){
if (isPrime(i)){
fseek (fp,0,SEEK_END);
if (ftell(fp)<67108843) {
fprintf(fp,"(2^%d)-1,",i);
}
else
{
file=file+1;
if (file==1) {
fp=fopen("sample1.txt","w");
fprintf(fp,"%d,",i);
}
if (file==2) {
fp=fopen("sample2.txt","w");
fprintf(fp,"%d,",i);
}
if (file==3) {
fp=fopen("sample3.txt","w");
fprintf(fp,"%d,",i);
}
if (file==4) {
fp=fopen("sample4.txt","w");
fprintf(fp,"%d,",i);
}
if (file==5) {
fp=fopen("sample5.txt","w");
fprintf(fp,"%d,",i);
}
if (file==6) {
fp=fopen("sample6.txt","w");
fprintf(fp,"%d,",i);
}
if (file==7) {
fp=fopen("sample7.txt","w");
fprintf(fp,"%d,",i);
}
if (file==8) {
fp=fopen("sample8.txt","w");
fprintf(fp,"%d,",i);
}
if (file==9) {
fp=fopen("sample9.txt","w");
fprintf(fp,"%d,",i);
}
if (file==10) {
fp=fopen("sample10.txt","w");
fprintf(fp,"%d,",i);
}
if (file==11) {
fp=fopen("sample11.txt","w");
fprintf(fp,"%d,",i);
}
if (file==12) {
fp=fopen("sample12.txt","w");
fprintf(fp,"%d,",i);
}
if (file==13) {
fp=fopen("sample13.txt","w");
fprintf(fp,"%d,",i);
}

}
}
}
return 0;
}


All times are UTC. The time now is 05:53.

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