numero_primo/main.c
2025-04-11 16:03:05 +02:00

25 lines
492 B
C

#include <stdio.h>
#include <stdlib.h>
typedef int bool;
const int true = 1;
const int false = 0;
int main(){
int numero;
bool divisibile = false;
printf("Inserire un numero: ");
scanf("%i", &numero);
for (int i = 2; i < numero - 1 && divisibile == false; i++){
if(numero%i==0){
divisibile = true;
printf("%i non è primo", numero);
}
}
if(divisibile==false){
printf("Il numero è primo.");
}
return 0;
}