Nice Job punching a hole there confuzor, I've found that if you multiply by other primes in those cases you can get further primes.
Example
41 * 7 = 287
287 - 2 = 285 -> Not Prime 287 + 2 = 289 -> {EDIT} Upon Further Research, this number is not a prime, so although the above statement is somewhat correct, this example is a very bad case in point.
The problem with multiplying using higher primes is that they are less and less reliable.
Although not a definitive theory it could point to something more. So far the only exception appears to be 41, I'd be happy if people could point out any to me.
Any good theory needs refinement and a theory for primes has so far never been devised.
Feel free to play with it if you wan't to try any new ideas. 31 is the first prime for which it fails.
<!--QuoteBegin--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> </td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->//------------------------------------------------------------------------------------------------- //DEFINES //------------------------------------------------------------------------------------------------- //instructs compiler through header file logic not to include MFC stuff #define WIN32_LEAN_AND_MEAN
//program states #define STATE_INIT 1 #define STATE_RUN 2 #define STATE_QUIT 3 #define STATE_EXCEPTIONFOUND 4 #define STATE_ERROR 5 #define STATE_NOEXCEPTIONFOUND 6 //------------------------------------------------------------------------------------------------- //INCLUDES //------------------------------------------------------------------------------------------------- #include <windows.h> //Not needed for this stuff #include <windowsx.h> #include <math.h> //sqrt #include <stdlib.h> //ltoa #include <string.h> //strcat //------------------------------------------------------------------------------------------------- //GLOBALS //------------------------------------------------------------------------------------------------- int state=STATE_INIT; int error=0;
//only test this far const unsigned long limit=1000; //------------------------------------------------------------------------------------------------- //FUNCTION DECLARATIONS //------------------------------------------------------------------------------------------------- bool IsPrime(unsigned long n); //returns true (i.e. 1) if prime, false (i.e. 0) if not //------------------------------------------------------------------------------------------------- //WINMAIN //-------------------------------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpcmdline, int nCMDShow) { //the number currently being tested unsigned long CurrentNumber=1;
//main event loop while(state!=STATE_QUIT) { switch (state) { case STATE_INIT: { //do initialization of stuff here if needed
//set state to run state=STATE_RUN; } break; case STATE_RUN: { //for performance reasons, do all testing without going through the switch while(state==STATE_RUN) { if(IsPrime(CurrentNumber)) { bool temp[2]; temp[0]=IsPrime(3*CurrentNumber+2); temp[1]=IsPrime(3*CurrentNumber-2);
//if exception found, set state to exceptionfound if (!temp[0]&&!temp[1]) //if neither are true then both are false { state = STATE_EXCEPTIONFOUND; break; //quit the while statement without incrementing CurrentNumber by 2 } } //end of if
/*don't bother testing with even numbers, they are divisible by 2, 2 is the only even prime number. this if statement adds a small overhead which is negligible compared to the time it takes to test if large numbers are prime*/ if(CurrentNumber<=2) { CurrentNumber++; } else { CurrentNumber+=2; }
/*if you run out of numbers smaller than the set limit to test, set the state to no exception found*/ if(CurrentNumber>limit) state=STATE_NOEXCEPTIONFOUND;
} //end of while } break; case STATE_EXCEPTIONFOUND: { //to output the first number for which the rule fails conversion to a string is needed char Current[11]; //a long contains 10 figures at most, 11 is needed for a null sign char Message[500]="\n"; //un-necessarily long, but I don't wan't buffer overflows
//convert CurrentNumber to a number and stick it in the string Current ltoa(CurrentNumber,Current,10);
//add the strings together back to back and put in Message strcat(Message,"OMG an exception was teh found!!!111\n\n"); strcat(Message,"The prime "); strcat(Message,Current); strcat(Message," does not generate any new primes when multiplied by 3 and added to 2 or -2");
//pop up a message box saying an exception was found MessageBox( NULL, Message, "ah crap", MB_OK|MB_ICONEXCLAMATION);
//set state to quit state = STATE_QUIT; } break; case STATE_NOEXCEPTIONFOUND: { //pop up a message box saying no exception was found MessageBox( NULL, "no exception was found among the tested primes", "yay", MB_OK|MB_ICONEXCLAMATION);
//set state to quit state = STATE_QUIT; } break; case STATE_ERROR: { //pop up a message box saying an error was found MessageBox( NULL, "an error was encountered", "oh noes!!!11", MB_OK|MB_ICONSTOP);
//set state to quit state = STATE_QUIT; } break; case STATE_QUIT: { /*do cleanup if needed. program will exit the while-loop and quit*/ } break; default: break; } //end of switch }//end of while return (error); //if error!=0 an error was encountered }
//returns true if n is prime and false if not bool IsPrime(unsigned long n) { /*don't bother testing if integers above the squareroot are factors, if a number larger the square root is a factor then the other factor is smaller than the squareroot*/
//explicit type casting to unsigned long chops of the decimals. unsigned long testlimit = (unsigned long)sqrt((double)n);
//don't bother testing if 1 or 2 is factors unsigned long counter;
/*test if any factors are found, don't bother finding even factors. A number divisible with an even number k, is also divisible by k/2.*/ for (counter=3;counter<=testlimit;counter+=2) { //if n is evenly divisible with counter it is not prime, return false if(n%counter==0) return (false); } //end of for
//if you get this far the number is not evenly divisible with any number but itself and 1 return(true); }<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
Gah... why are tabs shortened to 1 space? It makes it horrible to read...
Grab it here if you want it instead of copy paste <a href='http://hem.bredband.net/congal/temp/prime.zip' target='_blank'>prime.zip</a>
I don't know if its already been said, but 1 is not a prime.
While a prime number is a number that can only be divided exactly by 1 and itself, 1 is usually excluded from this definition.
The reason is so that every positive integer greater than 1 can be expressed uniquely as a product of primes. For example, if we did allow 1 as a prime, then 6 = 2×3 = 1×2×3 = 1×1×2×3 etc. and uniqueness is lost.
AllUrHiveRblong2usBy Your Powers Combined...Join Date: 2002-12-20Member: 11244Members
<!--QuoteBegin--Cronos+Jan 5 2004, 12:16 AM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Cronos @ Jan 5 2004, 12:16 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> 287 + 2 = 289 -> {EDIT} Upon Further Research, this number is not a prime <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd--> For some reason, that made me almost fall out of my seat laughing. That has made my day, and it's not even 6:15 yet!
tankefuglOne Script To Rule Them All...Trondheim, NorwayJoin Date: 2002-11-14Member: 8641Members, Retired Developer, NS1 Playtester, Constellation, NS2 Playtester, Squad Five Blue
Ok, some small notes:
Mathematical induction can indeed be used on primes, [WHO]Them.
Mathematical induction is not the ONLY way to prove something (but it's actually the only way of proving something without the need of understanding why).
Soylent green disproved the original theory by a counterexample. The original theory, however, was NOT proved -- it was just a couple of examples listed. Examples can not prove anything, but they can disprove.
DOOManiac's teorem still stands, though. Makes perfect sense.
<!--QuoteBegin--Bosnian+Jan 4 2004, 11:33 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Bosnian @ Jan 4 2004, 11:33 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> I'm taking the second. I've failed all math subjects I've taken in high school at least once. But I somehow managed to get through and still stay only one year behind. <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd--> hah, same here im in 2 too, i managed to get a 65 on my math 1 alg regents (well with the curve)
Math sucks, i hate it, its brining my grades down and no matter how hard i try or how long i study i still fail 90% of my math tests... math just isnt for me
Comments
Example
41 * 7 = 287
287 - 2 = 285 -> Not Prime
287 + 2 = 289 -> {EDIT} Upon Further Research, this number is not a prime, so although the above statement is somewhat correct, this example is a very bad case in point.
The problem with multiplying using higher primes is that they are less and less reliable.
Although not a definitive theory it could point to something more. So far the only exception appears to be 41, I'd be happy if people could point out any to me.
Any good theory needs refinement and a theory for primes has so far never been devised.
Feel free to play with it if you wan't to try any new ideas. 31 is the first prime for which it fails.
<!--QuoteBegin--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> </td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->//-------------------------------------------------------------------------------------------------
//DEFINES
//-------------------------------------------------------------------------------------------------
//instructs compiler through header file logic not to include MFC stuff
#define WIN32_LEAN_AND_MEAN
//program states
#define STATE_INIT 1
#define STATE_RUN 2
#define STATE_QUIT 3
#define STATE_EXCEPTIONFOUND 4
#define STATE_ERROR 5
#define STATE_NOEXCEPTIONFOUND 6
//-------------------------------------------------------------------------------------------------
//INCLUDES
//-------------------------------------------------------------------------------------------------
#include <windows.h>
//Not needed for this stuff #include <windowsx.h>
#include <math.h> //sqrt
#include <stdlib.h> //ltoa
#include <string.h> //strcat
//-------------------------------------------------------------------------------------------------
//GLOBALS
//-------------------------------------------------------------------------------------------------
int state=STATE_INIT;
int error=0;
//only test this far
const unsigned long limit=1000;
//-------------------------------------------------------------------------------------------------
//FUNCTION DECLARATIONS
//-------------------------------------------------------------------------------------------------
bool IsPrime(unsigned long n); //returns true (i.e. 1) if prime, false (i.e. 0) if not
//-------------------------------------------------------------------------------------------------
//WINMAIN
//-------------------------------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpcmdline,
int nCMDShow)
{
//the number currently being tested
unsigned long CurrentNumber=1;
//main event loop
while(state!=STATE_QUIT)
{
switch (state)
{
case STATE_INIT:
{
//do initialization of stuff here if needed
//set state to run
state=STATE_RUN;
} break;
case STATE_RUN:
{
//for performance reasons, do all testing without going through the switch
while(state==STATE_RUN)
{
if(IsPrime(CurrentNumber))
{
bool temp[2];
temp[0]=IsPrime(3*CurrentNumber+2);
temp[1]=IsPrime(3*CurrentNumber-2);
//if exception found, set state to exceptionfound
if (!temp[0]&&!temp[1]) //if neither are true then both are false
{
state = STATE_EXCEPTIONFOUND;
break; //quit the while statement without incrementing CurrentNumber by 2
}
} //end of if
/*don't bother testing with even numbers, they are divisible by 2,
2 is the only even prime number.
this if statement adds a small overhead which is negligible compared
to the time it takes to test if large numbers are prime*/
if(CurrentNumber<=2)
{
CurrentNumber++;
}
else
{
CurrentNumber+=2;
}
/*if you run out of numbers smaller than the set limit to test,
set the state to no exception found*/
if(CurrentNumber>limit) state=STATE_NOEXCEPTIONFOUND;
} //end of while
} break;
case STATE_EXCEPTIONFOUND:
{
//to output the first number for which the rule fails conversion to a string is needed
char Current[11]; //a long contains 10 figures at most, 11 is needed for a null sign
char Message[500]="\n"; //un-necessarily long, but I don't wan't buffer overflows
//convert CurrentNumber to a number and stick it in the string Current
ltoa(CurrentNumber,Current,10);
//add the strings together back to back and put in Message
strcat(Message,"OMG an exception was teh found!!!111\n\n");
strcat(Message,"The prime ");
strcat(Message,Current);
strcat(Message," does not generate any new primes when multiplied by 3 and added to 2 or -2");
//pop up a message box saying an exception was found
MessageBox(
NULL,
Message,
"ah crap",
MB_OK|MB_ICONEXCLAMATION);
//play annoying beep noise
MessageBeep(MB_ICONEXCLAMATION);
//set state to quit
state = STATE_QUIT;
} break;
case STATE_NOEXCEPTIONFOUND:
{
//pop up a message box saying no exception was found
MessageBox(
NULL,
"no exception was found among the tested primes",
"yay",
MB_OK|MB_ICONEXCLAMATION);
//play annoying beep noise
MessageBeep(MB_ICONEXCLAMATION);
//set state to quit
state = STATE_QUIT;
} break;
case STATE_ERROR:
{
//pop up a message box saying an error was found
MessageBox(
NULL,
"an error was encountered",
"oh noes!!!11",
MB_OK|MB_ICONSTOP);
//play annoying beep noise
MessageBeep(MB_ICONEXCLAMATION);
//set state to quit
state = STATE_QUIT;
} break;
case STATE_QUIT:
{
/*do cleanup if needed.
program will exit the while-loop and quit*/
} break;
default: break;
} //end of switch
}//end of while
return (error); //if error!=0 an error was encountered
}
//returns true if n is prime and false if not
bool IsPrime(unsigned long n)
{
/*don't bother testing if integers above the squareroot are factors,
if a number larger the square root is a factor then the other factor is smaller than the squareroot*/
//explicit type casting to unsigned long chops of the decimals.
unsigned long testlimit = (unsigned long)sqrt((double)n);
//don't bother testing if 1 or 2 is factors
unsigned long counter;
/*test if any factors are found, don't bother finding even factors.
A number divisible with an even number k, is also divisible by k/2.*/
for (counter=3;counter<=testlimit;counter+=2)
{
//if n is evenly divisible with counter it is not prime, return false
if(n%counter==0) return (false);
} //end of for
//if you get this far the number is not evenly divisible with any number but itself and 1
return(true);
}<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
Gah... why are tabs shortened to 1 space? It makes it horrible to read...
Grab it here if you want it instead of copy paste <a href='http://hem.bredband.net/congal/temp/prime.zip' target='_blank'>prime.zip</a>
can't argue with the facts.
While a prime number is a number that can only be divided exactly by 1 and itself, 1 is usually excluded from this definition.
The reason is so that every positive integer greater than 1 can be expressed uniquely as a product of primes. For example, if we did allow 1 as a prime, then 6 = 2×3 = 1×2×3 = 1×1×2×3 etc. and uniqueness is lost.
For some reason, that made me almost fall out of my seat laughing. That has made my day, and it's not even 6:15 yet!
Transformer + Samus love?
<!--emo&:0--><img src='http://www.unknownworlds.com/forums/html/emoticons/wow.gif' border='0' style='vertical-align:middle' alt='wow.gif'><!--endemo-->
Mathematical induction can indeed be used on primes, [WHO]Them.
Mathematical induction is not the ONLY way to prove something (but it's actually the only way of proving something without the need of understanding why).
Soylent green disproved the original theory by a counterexample. The original theory, however, was NOT proved -- it was just a couple of examples listed. Examples can not prove anything, but they can disprove.
DOOManiac's teorem still stands, though. Makes perfect sense.
With a bit of work a proper pattern may be found.
//raises imaginary wine glass
To Pure Science, May it Be Of No Use To Anyone!
I like the sound of that! How do I apply for the mathmatical name patent or whatever it is!? :D
The good news is i'm going to pass P1.... this time. The bad news is im probaly going to flunk P2 big time.
hah, same here im in 2 too, i managed to get a 65 on my math 1 alg regents (well with the curve)
Math sucks, i hate it, its brining my grades down and no matter how hard i try or how long i study i still fail 90% of my math tests... math just isnt for me
Yes, and:
Let X = <!--emo&::marine::--><img src='http://www.unknownworlds.com/forums/html/emoticons/marine.gif' border='0' style='vertical-align:middle' alt='marine.gif'><!--endemo--> <!--emo&::marine::--><img src='http://www.unknownworlds.com/forums/html/emoticons/marine.gif' border='0' style='vertical-align:middle' alt='marine.gif'><!--endemo-->
Let Y = <!--emo&::onos::--><img src='http://www.unknownworlds.com/forums/html/emoticons/tiny.gif' border='0' style='vertical-align:middle' alt='tiny.gif'><!--endemo-->
X + Y = Y.
Ok that didnt exactly make sense.