#include <stdio.h>
char *input_1 = "11"; // al posto di argv[1];
unsigned int
primo (int x)
{
unsigned int primo = 1;
int i = 2;
int j;
while ((i < x) && primo)
{
j = x / i;
j = x - (j * i);
if (j == 0)
{
primo = 0;
}
else
{
i++;
}
}
return primo;
}
int
main (int argc, char *argv[])
{
int x;
if (primo (x))
{
printf ("%i è un numero primo\n", x
); }
else
{
printf ("%i non è un numero primo\n", x
); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpjaGFyICppbnB1dF8xID0gIjExIjsgIC8vIGFsIHBvc3RvIGRpIGFyZ3ZbMV07Cgp1bnNpZ25lZCBpbnQKcHJpbW8gKGludCB4KQp7CiAgICB1bnNpZ25lZCBpbnQgcHJpbW8gPSAxOwogICAgaW50IGkgPSAyOwogICAgaW50IGo7CgogICAgd2hpbGUgKChpIDwgeCkgJiYgcHJpbW8pCiAgICAgIHsKICAgICAgICBqID0geCAvIGk7CiAgICAgICAgaiA9IHggLSAoaiAqIGkpOwoKICAgICAgICBpZiAoaiA9PSAwKQogICAgICAgICAgewogICAgICAgICAgICBwcmltbyA9IDA7CiAgICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgICAgewogICAgICAgICAgICBpKys7CiAgICAgICAgICB9CiAgICAgIH0KCiAgICByZXR1cm4gcHJpbW87Cn0KCmludAptYWluIChpbnQgYXJnYywgY2hhciAqYXJndltdKQp7CiAgICBpbnQgeDsKCiAgICBzc2NhbmYgKGlucHV0XzEsICIlaSIsICZ4KTsKCiAgICBpZiAocHJpbW8gKHgpKQogICAgICB7CiAgICAgICAgcHJpbnRmICgiJWkgw6ggdW4gbnVtZXJvIHByaW1vXG4iLCB4KTsKICAgICAgfQogICAgZWxzZQogICAgICB7CiAgICAgICAgcHJpbnRmICgiJWkgbm9uIMOoIHVuIG51bWVybyBwcmltb1xuIiwgeCk7CiAgICAgIH0KCiAgICByZXR1cm4gMDsKfQ==