#include <stdlib.h>
#include <math.h>
#include <stdio.h>
/*usuario entra com um numero, o programa devera imprimir o maior numero primo entre 1 e o numero digitado*/
int main() {
int num, i, j, aux, cont;
aux = 0;
for (i = num; i >= 2; --i) {
cont = 0;
for (j
= 2; j
< sqrt(i
) + 1; ++j
) { if (i % j == 0) {
cont++;
break;
}
}
if (cont == 0) {
aux = i;
break;
}
}
printf("O maior numero primo entre 0 e %d sera %d", num
, aux
); return 0;
}
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8bWF0aC5oPgojaW5jbHVkZSA8c3RkaW8uaD4KCi8qdXN1YXJpbyBlbnRyYSBjb20gdW0gbnVtZXJvLCBvIHByb2dyYW1hIGRldmVyYSBpbXByaW1pciBvIG1haW9yIG51bWVybyBwcmltbyBlbnRyZSAxIGUgbyBudW1lcm8gZGlnaXRhZG8qLwoKaW50IG1haW4oKSB7CiAgICBpbnQgbnVtLCBpLCBqLCBhdXgsIGNvbnQ7CiAgICBhdXggPSAwOwogICAgcHJpbnRmKCJkaWdpdGUgdW0gbnVtZTpcbiIpOwogICAgc2NhbmYoIiVpIiwgJm51bSk7CgogCWZvciAoaSA9IG51bTsgaSA+PSAyOyAtLWkpIHsKIAkJY29udCA9IDA7CgkJZm9yIChqID0gMjsgaiA8IHNxcnQoaSkgKyAxOyArK2opIHsKCQkJaWYgKGkgJSBqID09IDApCXsKCQkgICAgICAgIGNvbnQrKzsKICAgICAgICAgICAgICAgIGJyZWFrOwoJCQl9CgkJfQoJCWlmIChjb250ID09IDApIHsKCQkJYXV4ID0gaTsKCQkJYnJlYWs7CgkJfQoJfQpwcmludGYoIk8gbWFpb3IgbnVtZXJvIHByaW1vIGVudHJlIDAgZSAlZCBzZXJhICVkIiwgbnVtLCBhdXgpOwpyZXR1cm4gMDsKfQ==