1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-11-09 22:08:58 +01:00
programming-challenges/challenges/is-prime-number/solutions/c/function/solution.c

21 lines
406 B
C

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
bool is_prime_number(int number) {
for (int iteration = 2; iteration < number; iteration++) {
if (number % iteration == 0) {
return false;
}
}
return true;
}
int main() {
int number;
scanf("%d", &number);
bool is_prime = is_prime_number(number);
printf("%s\n", is_prime ? "true" : "false");
return EXIT_SUCCESS;
}