Here's an example. I've included analysis.
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
/* User inputs high and low ends of range to search.
/ This could easily be done as function inputs, if
/ if so desired. */
int testprime,testdivisor, minprime, maxprime;
printf("Search for primes between:\nLow end: ");
scanf("%d",minprime);
printf("Top end: ");
scanf("%d",maxprime);
int isprime; // 0 indicates a number is not prime..
for(testprime=minprime;testprime<=maxprime;testprime++)
{
isprime = 1;
for(testdivisor=2;testdivisor<sqrt(testprime);testdivisor++) // Primes divide by 1!
{
isprime = testprime%testdivisor; // % finds remainders, so 7%3 returns 1.
// If 0 is returned, a divisor has been found.
if(isprime == 0) break; // Hence, not prime. "break;" exits the loop.
}
if(isprime != 0) printf("%d is prime.\n",testprime);
}
system("pause");
return 0;
}
By learning how to program on C+.
3n+8=a To find the value of n, you need to know the value of a.
A prime plus another prime is at the very least going to be an even number since all primes (with the exception of 2) are odd.
No. (5x3x17) + 17 =255 + 17 =272 (This is not prime.)
The numbers are 13 and 41. And you do not need to know that they are prime in order to find the answer. The sum (54) and difference (28) provide all the necessary information.
a prime number is a number that you can plus by one
By learning how to program on C+.
47 + 7
3n+8=a To find the value of n, you need to know the value of a.
A prime plus another prime is at the very least going to be an even number since all primes (with the exception of 2) are odd.
No. it's not a prime number when x = 40, 41, 81,82 ...
#include <iostream.h> main() { int a; cout<<"enter a number : "; cin>>a; cout<<endl; if (a%2-1) cout<<"it is a prime number"; else cout<<"it is not a prime number" return 0; } ------------------------------------------ output: enter a number : 30 it is a not a prime number
No. (5x3x17) + 17 =255 + 17 =272 (This is not prime.)
The numbers are 13 and 41. And you do not need to know that they are prime in order to find the answer. The sum (54) and difference (28) provide all the necessary information.
No. The number 38,482 is composite.
bghjg
n = 5.