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 q) //verifica se um numero é primo
- {
- int resultado;
- if (numero%(q-1) == 0 && (q-1) != 1)
- {
- resultado = 1;
- }
- else if ((q-1) > 2)
- {
- verificaPRIMO(q-1);
- }
- else
- {
- resultado = 0;
- }
- return resultado;
- }
- void scan()
- {
- int x;
- scanf("%d",&x);
- static int numero;
- numero = x; //atribui o valor do numero ao valor que x receberá
- if (x == -1)
- {
- return;
- }
- else
- {
- printf("%d\n",verificaPRIMO(x));
- scan();
- }
- }
- int main ()
- {
- int numero_base;
- scanf("%d",&numero_base);
- static int numero;
- numero = numero_base; //atribui o valor do numero ao numero base
- if (numero_base == -1)
- {
- return 0;
- }
- else
- {
- printf("%d\n",verificaPRIMO(numero_base));
- scan();
- }
- }
- // recebe numeros
- // dividir esses numeros pelos anteriores até que x-1 = 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement