// ex_ch7_9.c
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
	int number;
	int number_to_check, divisor;
	bool is_prime;

	printf("Insert a number: ");
	scanf("%d", &number);

	// check all numbers that are larger than 2 and <= the inserted numbers
	// thether they are prime or nor
	for (number_to_check = 2; number_to_check <= number; number_to_check++)
	{
		//printf("Is prime: %d?\n", number_to_check);
		// first, assume they are prime
		is_prime = true;
		// check all numbers that are >= 2 and smaller then the number to check
		for (divisor = 2; divisor < number_to_check; divisor++)
		{
			// if the rest of the division is zero, this number cannot be prime
			if (number_to_check % divisor == 0)
				is_prime = false;
		}
		if (is_prime)
			printf("%d ", number_to_check);
	}
	printf("\n");
	return 0;
}