1
Algorithm to find out if a number is prime, giving the floating point excess error.
#include<stdio.h>
int main(){
int n, i, divisivel;
divisivel =0;
printf("Digite um numero para saber se eh primo: \n");
scanf("%d", &n);
for(i = n; i >= 0; i--){
if(n%i == 0){
divisivel =divisivel + 1;
}
}
if(divisivel <=2){
printf("o numero %i eh primo!: \n", n);
}else{
printf("o numero %i não eh primo \n", n);
}
return (0);
}
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site
– Maniero