right prime numbers



i need to develop a code that finds a prime right number between 2 and
100000. and print one line of text that indicates if the int. is right
prime. i am in beginning programing so complex is complicated. we are
on a functions chapter. i am usung the square root to find the prime.
so far i have accomplished this but i cant fgure how to divide this by
ten so i can find the right prime. i am using c.



#include <stdio.h>
#include <math.h>


int slowPrime(int); //function prototype

int main()
{
int x; // loop counter
int count = 0; // total numbers of prime found
long prime;


printf_s("The prime numbers from 1 to 10000 are:\n" );


for ( x = 2; x <= 2147483647 ; x++ )
{
if ( Prime( x ) )
{
++count; // count and print prime
//printf_s("%10d", x );

if ( count % 10 == 0 ) // new line after 10 values diplayed
printf_s( "\n" );
} // end for
} // end if




printf_s("%d prime numbers were found\n", count);

return 0; // indicate successful termination
} // end main

int isRightPrime( int n ) // slow prime returns 1 if n is prime
{
int i; // loop counter

for ( i = 2; i <= (int)sqrt (n); i++ )
{
if ( n % i == 0 )
return 0;

} // end for

return 1;

} // end function prime



i know this can not be as complicated as i have made it.

.



Relevant Pages

  • Re: right prime numbers
    ... and print one line of text that indicates if the int. ... int x; // loop counter ... int IsRightPrime(unsigned long long int PrimeNumber) ... int i, lastchar; ...
    (comp.lang.c)
  • Re: right prime numbers
    ... and print one line of text that indicates if the int. ... you never declare this function ... int x; // loop counter ... make it so simple that there are obviously no deficiencies, ...
    (comp.lang.c)
  • Re: Implementation-defined behaviour
    ... int main ... Only by quibbles: the form of "successful termination" ... returned to the host environment is implementation-defined, ...
    (comp.lang.c)