#include <stdlib.h>
#include <math.h>
int CalcularExponente (int num)
{
int exponente=0;
while (num > 0){
num /= 10;
exponente++;
}
exponente--;
return exponente;
}
int main ()
{
int j, num, digit, contador, mascara, exponente;
printf ("introduce un numero: ");
scanf ("%i", &num);
if (num < 0){
num *= -1;
}
exponente=CalcularExponente (num);
mascara=pow (10, exponente);
for (;num != 0;){
getchar ();
digit = (num/mascara);
num -= (digit*mascara);
mascara /= 10;
contador=0;
for (j=1;j < digit;j++){
if (digit%j==0){
contador++;
}
}
if (contador==1){
printf ("%d es primo\n",digit);
}else {
printf ("%d no es primo\n",digit);
}
}
return 0;
}