...
for(m = 6; m < n; m += 6){
if(isPrime(m - 1) && isPrime(m + 1)){
printf("(%i, %i)\n", m - 1, m + 1);
}
}
...
/*
a quick'n'dirty algorithm for checking if a number is prime or composite. Returns 1 if the number is prime, 0 otherwise. Takes advantages of the following facts:
}
}
return returnval;
}
Chat with our AI personalities
To find twin primes of a given number, iterate through the numbers starting from the given number, and for each number, check if both the number and the number+2 are prime. If they are, then they form a pair of twin primes with the given number.
Given an arbitrary odd natural number greater than five, x, let y = x - 3, then y is an even number greater than 2. By assumption we have that y is the sum of two primes, say y1 and y2, but then x = y1 + y2 + 3 (which is the sum of three primes).
Type your answer here... i think we should first enter 1 number then check it
it is a brute force way to find all the primes in a given range. Remove all the composites, and you are left with the primes
You can review about the number system in detail on the link given below Thanks