function main( )

{

 

   while (1)

   {

 

      display "";

      display "************************************************";

      display "Want to find all primes less than n! ";

      display "What is your value of n this time? ";

 

      read n;

 

      display "";

      display "The following are all the primes less than ", n;

 

      allPrimesLessThan(n);

 

   }

 

}

 

 

function allPrimesLessThan(y)

{

   count = 0;

   num = 2;

   while (num < y)

   {

      status = isPrime(num);

      if ( status )

      {

         count = count +1;

         display num, " is a prime.";

      }

      num = num+1;

   }

   return count;

}

 

 

 

function isPrime(x)

{

  if (x<2)   return 0;

  candidate = 2;

  while (candidate < x)

    {

       if ( (x % candidate) == 0 )  

          return 0;

       candidate = candidate +1;

 

   }

  return 1;

}