Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://thehuxley.com/problem/972
- #include <stdio.h>
- #include <math.h>
- int verificaPRIMO(int x, int y) //verifica se um numero é primo
- {
- if (x%y == 0 && y==1)
- {
- return 1;
- }
- else if (x%y == 0 && y != 1)
- {
- return 0;
- }
- else
- {
- return verificaPRIMO(x,--y);
- }
- }
- void scan()
- {
- int x;
- scanf("%d",&x);
- if (x == -1)
- {
- return;
- }
- else
- {
- printf("%d\n",verificaPRIMO(x,x));
- scan();
- }
- }
- int main ()
- {
- int numero_base;
- scanf("%d",&numero_base);
- if (numero_base == -1) //finalizar o programa se input == -1
- {
- return 0;
- }
- else
- {
- printf("%d\n",verificaPRIMO(numero_base,numero_base));
- scan();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement