#include "func_math.h"
#include "func_premier.h"

//-----[ Premier ]---------------------------------------------------------

unsigned int premier(unsigned int x)
{
  unsigned int it;

  if (x <= 0)
    return 0;
  
  if (x <= 2)
    return 1;

  for(it=2; it <= (x/2); it++)
    if (modulo(x,it) == 0)
      return 0;
  
  return 1;
}

unsigned int n_premier(unsigned int nieme_premier)
{
  unsigned int nb_find  = 0;
  unsigned int res      = 1;
  while (nb_find < nieme_premier)
    {
      res ++;
      if (premier(res) == 1)
        nb_find ++;
    }
  return res;
}

