Solving math problems with Programming -
02-07-2012, 12:09 AM
programmers!
i need help on a math problem...
is it okay to post here?
Are there any prime numbers with differences of 3?
e.g. 2 and 5 (they're not prime)
is it possible to solve that with programming?
For example to find if 'how many positive integers less than 1000 do not have 7 as their digit'
private int doit()
{
int rwcnt=0;
for (int i=0; i< 1000;i++)
{
string stri = Convert.ToString(i);
if (stri.IndexOf("7") == -1) {rwcnt++;}
}
return rwcnt;
}
2 and 5 are prime and are the only prime numbers that are three apart. This is because all prime numbers are odd, and an odd number plus 3 makes an even number. 2 is the only even prime number, meaning two and five are the only prime numbers with a difference of three.